-
Notifications
You must be signed in to change notification settings - Fork 858
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
Error loading a saved LabelModel and using it to predict #1460
Comments
Thank you posting details of this error, we were able to reproduce it. The We will fix this bug in the upcoming release. Here's a modification to your example that will get it working: import numpy as np
import snorkel.labeling
L_train = np.random.randint(-1, 2, size=(10**6, 10), dtype=np.int8)
lm = snorkel.labeling.LabelModel()
lm.fit(L_train)
lm.save('label_model.pt')
#an additional call to .fit() with a dummy L here
L_train_dummy = np.random.randint(-1, 2, size=(10**6, 10), dtype=np.int8)
lm2 = snorkel.labeling.LabelModel()
lm2.fit(L_train_dummy)
lm2.load('label_model.pt')
lm2.predict(L_train)
#check predictions are as expected
original_preds = lm.predict(L_train)
loaded_preds = lm2.predict(L_train)
np.sum(original_preds != loaded_preds) #should return 0 |
@paroma Thanks a lot for looking into this and suggesting a work around. Could you explain what I tried to run
Could you explain what the tensor |
|
Issue description
I wanted to save a label model trained within a jupyter notebook and use it in standalone python scripts elsewhere.
I used snorkel.labeling.LabelModel.save() method to save the model. Then, I loaded the model using the snorkel.labeling.LabelModel.load() method and it throws the following error:
AttributeError: 'LabelModel' object has no attribute 'c_tree'
Code example/repro steps
Error stack trace
System info
conda
Windows 10
3.7.4
0.9.0
The text was updated successfully, but these errors were encountered: