DeepCube-org / uc3-public-notebooks

Notebooks accessing UC3 datasets
10 stars 2 forks source link

Issues loading ConvLSTM fire model #1

Closed RiccardoGrigoletto closed 2 years ago

RiccardoGrigoletto commented 2 years ago

I am trying the notebooks on the Hopsworks platform.

In the second notebook (uc3-public-notebooks-main/2_UC3_DL_models_inference.ipynb), when I run convlstm = ConvLSTM_fire_model(**best_settings[model]).load_from_checkpoint(path_convlstm) it throws an error.

Here is the traceback.

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-34-e7bd68891186> in <module>
      2 
      3 model = 'convlstm'
----> 4 convlstm = ConvLSTM_fire_model(**best_settings[model]).load_from_checkpoint(path_convlstm)

/srv/hops/staging/private_dirs/3df99fe2aee2df02abf1fd5010342a35f5b5e36320d0a6ba7b2033f4138852b3/localized_deps/greece_fire_models.py in __init__(self, dynamic_features, static_features, hidden_size, lstm_layers, lr, positive_weight, lr_scheduler_step, lr_scheduler_gamma, weight_decay)
     38         self.save_hyperparameters()
     39 
---> 40         self.model = SimpleConvLSTM(hparams=self.hparams)
     41 
     42         # loss function

/srv/hops/staging/private_dirs/3df99fe2aee2df02abf1fd5010342a35f5b5e36320d0a6ba7b2033f4138852b3/localized_deps/fire_modules.py in __init__(self, hparams)
     61                                  True,
     62                                  True,
---> 63                                  False)
     64 
     65         kernel_size = 3

/srv/hops/staging/private_dirs/3df99fe2aee2df02abf1fd5010342a35f5b5e36320d0a6ba7b2033f4138852b3/localized_deps/convlstm.py in __init__(self, input_dim, hidden_dim, kernel_size, num_layers, batch_first, bias, return_all_layers)
     91     def __init__(self, input_dim, hidden_dim, kernel_size, num_layers,
     92                  batch_first=False, bias=True, return_all_layers=False):
---> 93         super(ConvLSTM, self).__init__()
     94 
     95         self._check_kernel_size_consistency(kernel_size)

TypeError: super(type, obj): obj must be an instance or subtype of type

The other models (LSTM and CNN) can be loaded correctly multiple times.

Do you know what could be the issue?

Thanks

iprapas commented 2 years ago

This seems to be related to https://stackoverflow.com/questions/43751455/supertype-obj-obj-must-be-an-instance-or-subtype-of-type and https://github.com/jupyter/help/issues/130.

RiccardoGrigoletto commented 2 years ago

I solved the error with changing the line

https://github.com/DeepCube-org/uc3-public-notebooks/blob/45fea77035b8307afc6ab1602b30b1d698930271/src/modules/convlstm.py#L93

to super().__init__()

RiccardoGrigoletto commented 2 years ago

But you are correct, it's Jupyter that messes up with the module reloading.