Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dtype handling for labels in the map file #21

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions python-package/SLIM/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -625,10 +625,11 @@ def save_model(self, modelfname, mapfname):
else:
raise RuntimeError("Not exist a model to save.")

def load_model(self, modelfname, mapfname):
def load_model(self, modelfname, mapfname, map_dtype=np.int32):
''' @brief load a model
@params modelfname: filename of the model
mapfname: filename of the item map
map_dtype: data type of the map labels
@return None
'''
# if there is a model, destruct the model
Expand All @@ -641,7 +642,7 @@ def load_model(self, modelfname, mapfname):
byref(self.handle), c_char_p(modelfname.encode('utf-8')))

try:
self.id2item = np.genfromtxt(mapfname, dtype=np.int32)
self.id2item = np.genfromtxt(mapfname, dtype=map_dtype)
except:
self.id2item = np.genfromtxt(mapfname)
self.item2id = {}
Expand Down