lasso-net / lassonet

Feature selection in neural networks

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TypeError: Expected state_dict to be dict-like, got <class 'NoneType'>.

sddthree opened this issue · comments

TypeError: Expected state_dict to be dict-like, got <class 'NoneType'>.

When I runing example : python friedman.py
path_multiplier: 1.01
M: 10
Traceback (most recent call last):
File "friedman.py", line 53, in
min(rrmse(y_test, model.load(save).predict(X_test)) for save in path),
File "friedman.py", line 53, in
min(rrmse(y_test, model.load(save).predict(X_test)) for save in path),
File "/opt/conda/envs/lassonet/lib/python3.8/site-packages/lassonet-0.0.15-py3.8.egg/lassonet/interfaces.py", line 524, in load
self.model.load_state_dict(state_dict)
File "/opt/conda/envs/lassonet/lib/python3.8/site-packages/torch/nn/modules/module.py", line 2140, in load_state_dict
raise TypeError(f"Expected state_dict to be dict-like, got {type(state_dict)}.")
TypeError: Expected state_dict to be dict-like, got <class 'NoneType'>.

since my cuda is 12, so my torch using the latest versin.
torch 2.3.0
torchvision 0.18.0

how to solve it?

set return_state_dicts=True

@louisabraham is it possible to set
return_state_dicts=True
as default value across interfaces.py? LassoNet breaks without setting it to be true.

The reason why I didn't put it as default is because of the large memory consumption.
I could add some logic to make the error message more clear.