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
TypeError: __init__() got an unexpected keyword argument 'n_indep_decoder' #374
Comments
Yes if you init the tabnet algo with this code "loaded_clf = TabNetClassifier()" then the 'n_indep_decoder' is going to be missed from the model. So it won't be able to load it. |
Hello @balazsgonczy, Can you share a bit more information and ideally a reproducible error code where you save a model that can't be loaded back? |
Hello @Optimox, I have used the forest example on my own data. Then I saved the model. There I could load it back without issue. But if I wanted to load the model to a new Jupyther notebook then it didn't worked. So I have to retrain the model each time I run my workflow in order to proceed with my task. The main issue is what I have written. When you load back a model and before that you init the model like this: loaded_clf = TabNetClassifier() it won't match your saved model. Also I tried to init the missing parts like this: loaded_clf ="TabNetClassifier(n_indep_decoder=1)", but it retrieved the same error message. I think the error arises from the init not being able to predefine certain parameters like shadder or indep_decoder. So I would check it out. What considers the reproducible code... It is for a competition so I can only share it after the deadline. Best, Balázs |
I think what is most likely is that you have different versions of pytorch-tabnet installed in your different environments. So when you save your model the architecture is different between the two environments, hence your error when loading the weights. Can you make sure that both environments have the exact same version and retry ? |
About reproducible errors : you do not need to give your full code (also it's better if I don't need to review an entire pipeline). You should be able to reproduce your error with a randomly generated X_train, y_train. If you manage to reproduce your error within a very simple setting that can be reproduce I can investigate directly what is going on. Otherwise I'm in the dark. |
pytorch_tabnet version: NA - in the forest notebook? |
I doubt this could be the issue. I am using Vscode + Jupyther Notebook with similar packages. I haven't created virtual environment for them so... |
My notebook: Click to view session informationdownload 0.3.5
|
how are you installing pytorch-tabnet ? with pip? from source? what is the result of |
@balazsgonczy any news? |
I'm closing this since I'm not able to reproduce the error, please reopen with more information or a reproducible code. |
Hi,
I am trying to load a saved Tabnet model trained with your github repo.
Code:
from pytorch_tabnet.tab_model import TabNetClassifier
loaded_clf = TabNetClassifier()
loaded_clf.load_model("C:/Users/goncz/Desktop/test_model.zip")
Error message:
Device used : cpu
TypeError Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_3000/3925200397.py in
1 loaded_clf = TabNetClassifier()
----> 2 loaded_clf.load_model("C:/Users/goncz/Desktop/test_model.zip")
3
~\AppData\Local\Programs\Orange\lib\site-packages\pytorch_tabnet\abstract_model.py in load_model(self, filepath)
409 raise KeyError("Your zip file is missing at least one component")
410
--> 411 self.init(**loaded_params["init_params"])
412
413 self._set_network()
TypeError: init() got an unexpected keyword argument 'n_indep_decoder'
The text was updated successfully, but these errors were encountered: