GreatChenLab / Deep-B3

A multi-model framework for blood-brain barrier permeability discovery
14 stars 3 forks source link

RuntimeError: Error(s) in loading state_dict for ImageTabularTextModel #4

Open Khadorstorm opened 1 year ago

Khadorstorm commented 1 year ago

Hello, I got the following error when trainin the model with command python train.py train --feature train_feature.csv --epoch 50 --bs 64 --vis_out 512 --text_out 64 : Callbacks functions applied RNNTrainerSimple EarlyStoppingCallback SaveModelCallback 2023-10-29 04:05:52,813 - train.py[line:243] - INFO: the number of layer is 6 epoch train_loss valid_loss accuracy time 0 0.663310 #na# 01:12
1 0.646282 #na# 00:37 ---------------------------------------------------------------------| 16.47% [14/85 00:35<03:01 0.6458] Traceback (most recent call last): File "train.py", line 335, in has_text=args.has_text File "train.py", line 246, in train_deep_b3 learn.lr_find() File "D:\Software\Anaconda3\envs\pythonProject\lib\site-packages\fastai\train.py", line 41, in lr_find learn.fit(epochs, start_lr, callbacks=[cb], wd=wd) File "D:\Software\Anaconda3\envs\pythonProject\lib\site-packages\fastai\basic_train.py", line 200, in fit fit(epochs, self, metrics=self.metrics, callbacks=self.callbacks+callbacks) File "D:\Software\Anaconda3\envs\pythonProject\lib\site-packages\fastai\basic_train.py", line 112, in fit finally: cb_handler.on_train_end(exception) File "D:\Software\Anaconda3\envs\pythonProject\lib\site-packages\fastai\callback.py", line 323, in on_train_end self('train_end', exception=exception) File "D:\Software\Anaconda3\envs\pythonProject\lib\site-packages\fastai\callback.py", line 251, in call for cb in self.callbacks: self._call_and_update(cb, cb_name, kwargs) File "D:\Software\Anaconda3\envs\pythonProject\lib\site-packages\fastai\callback.py", line 241, in _call_andupdate new = ifnone(getattr(cb, f'on{cb_name}')(self.state_dict, **kwargs), dict()) File "D:\Software\Anaconda3\envs\pythonProject\lib\site-packages\fastai\callbacks\tracker.py", line 106, in on_train_end self.learn.load(f'{self.name}', purge=False) File "D:\Software\Anaconda3\envs\pythonProject\lib\site-packages\fastai\basic_train.py", line 273, in load get_model(self.model).load_state_dict(model_state, strict=strict) File "D:\Software\Anaconda3\envs\pythonProject\lib\site-packages\torch\nn\modules\module.py", line 1408, in load_state_dict self.class.name, "\n\t".join(error_msgs))) RuntimeError: Error(s) in loading state_dict for ImageTabularTextModel: Missing key(s) in state_dict: "cnn.0.0.weight", "cnn.0.1.weight", "cnn.0.1.bias", "cnn.0.1.running_mean", "cnn.0.1.running_var", "cnn.0.4.0.conv1.weight", "cnn.0.4.0.bn1.weight", "cnn.0 .4.0.bn1.bias", "cnn.0.4.0.bn1.running_mean", "cnn.0.4.0.bn1.running_var", "cnn.0.4.0.conv2.weight", "cnn.0.4.0.bn2.weight", "cnn.0.4.0.bn2.bias", "cnn.0.4.0.bn2.running_mean", "cnn.0.4.0.bn2.r unning_var", "cnn.0.4.0.conv3.weight", "cnn.0.4.0.bn3.weight", "cnn.0.4.0.bn3.bias", "cnn.0.4.0.bn3.running_mean", "cnn.0.4.0.bn3.running_var", "cnn.0.4.0.downsample.0.weight", "cnn.0.4.0.downs ample.1.weight", "cnn.0.4.0.downsample.1.bias", "cnn.0.4.0.downsample.1.running_mean", "cnn.0.4.0.downsample.1.running_var", "cnn.0.4.1.conv1.weight", "cnn.0.4.1.bn1.weight", "cnn.0.4.1.bn1.bia s", "cnn.0.4.1.bn1.running_mean", "cnn.0.4.1.bn1.running_var", "cnn.0.4.1.conv2.weight", "cnn.0.4.1.bn2.weight", "cnn.0.4.1.bn2.bias", "cnn.0.4.1.bn2.running_mean", "cnn.0.4.1.bn2.running_var", "cnn.0.4.1.conv3.weight", "cnn.0.4.1.bn3.weight", "cnn.0.4.1.bn3.bias", "cnn.0.4.1.bn3.running_mean", "cnn.0.4.1.bn3.running_var", "cnn.0.4.2.conv1.weight", "cnn.0.4.2.bn1.weight", "cnn.0.4.2. bn1.bias", "cnn.0.4.2.bn1.running_mean", "cnn.0.4.2.bn1.running_var", "cnn.0.4.2.conv2.weight", "cnn.0.4.2.bn2.weight", "cnn.0.4.2.bn2.bias", "cnn.0.4.2.bn2.running_mean", "cnn.0.4.2.bn2.runnin g_var", "cnn.0.4.2.conv3.weight", "cnn.0.4.2.bn3.weight", "cnn.0.4.2.bn3.bias", "cnn.0.4.2.bn3.running_mean", "cnn.0.4.2.bn3.running_var", "cnn.0.5.0.conv1.weight", "cnn.0.5.0.bn1.weight", "cnn .0.5.0.bn1.bias", "cnn.0.5.0.bn1.running_mean", "cnn.0.5.0.bn1.running_var", "cnn.0.5.0.conv2.weight", "cnn.0.5.0.bn2.weight", "cnn.0.5.0.bn2.bias", "cnn.0.5.0.bn2.running_mean", "cnn.0.5.0.bn2 .running_var", "cnn.0.5.0.conv3.weight", "cnn.0.5.0.bn3.weight", "cnn.0.5.0.bn3.bias", "cnn.0.5.0.bn3.running_mean", "cnn.0.5.0.bn3.running_var", "cnn.0.5.0.downsample.0.weight", "cnn.0.5.0.dow nsample.1.weight", "cnn.0.5.0.downsample.1.bias", "cnn.0.5.0.downsample.1.running_mean", "cnn.0.5.0.downsample.1.running_var", "cnn.0.5.1.conv1.weight", "cnn.0.5.1.bn1.weight", "cnn.0.5.1.bn1.b ias", "cnn.0.5.1.bn1.running_mean", "cnn.0.5.1.bn1.running_var", "cnn.0.5.1.conv2.weight", "cnn.0.5.1.bn2.weight", "cnn.0.5.1.bn2.bias", "cnn.0.5.1.bn2.running_mean", "cnn.0.5.1.bn2.running_var ", "cnn.0.5.1.conv3.weight", "cnn.0.5.1.bn3.weight", "cnn.0.5.1.bn3.bias", "cnn.0.5.1.bn3.running_mean", "cnn.0.5.1.bn3.running_var", "cnn.0.5.2.conv1.weight", "cnn.0.5.2.bn1.weight", "cnn.0.5. 2.bn1.bias", "cnn.0.5.2.bn1.running_mean", "cnn.0.5.2.bn1.running_var", "cnn.0.5.2.conv2.weight", "cnn.0.5.2.bn2.weight", "cnn.0.5.2.bn2.bias", "cnn.0.5.2.bn2.running_mean", "cnn.0.5.2.bn2.runn ing_var", "cnn.0.5.2.conv3.weight", "cnn.0.5.2.bn3.weight", "cnn.0.5.2.bn3.bias", "cnn.0.5.2.bn3.running_mean", "cnn.0.5.2.bn3.running_var", "cnn.0.5.3.conv1.weight", "cnn.0.5.3.bn1.weight", "c nn.0.5.3.bn1.bias", "cnn.0.5.3.bn1.running_mean", "cnn.0.5.3.bn1.running_var", "cnn.0.5.3.conv2.weight", "cnn.0.5.3.bn2.weight", "cnn.0.5.3.bn2.bias", "cnn.0.5.3.bn2.running_mean", "cnn.0.5.3.b n2.running_var", "cnn.0.5.3.conv3.weight", "cnn.0.5.3.bn3.weight", "cnn.0.5.3.bn3.bias", "cnn.0.5.3.bn3.running_mean", "cnn.0.5.3.bn3.running_var", "cnn.0.6.0.conv1.weight", "cnn.0.6.0.bn1.weig ht", "cnn.0.6.0.bn1.bias", "cnn.0.6.0.bn1.running_mean", "cnn.0.6.0.bn1.running_var", "cnn.0.6.0.conv2.weight", "cnn.0.6.0.bn2.weight", "cnn.0.6.0.bn2.bias", "cnn.0.6.0.bn2.running_mean", "cnn. 0.6.0.bn2.running_var", "cnn.0.6.0.conv3.weight", "cnn.0.6.0.bn3.weight", "cnn.0.6.0.bn3.bias", "cnn.0.6.0.bn3.running_mean", "cnn.0.6.0.bn3.running_var", "cnn.0.6.0.downsample.0.weight", "cnn. 0.6.0.downsample.1.weight", "cnn.0.6.0.downsample.1.bias", "cnn.0.6.0.downsample.1.running_mean", "cnn.0.6.0.downsample.1.running_var", "cnn.0.6.1.conv1.weight", "cnn.0.6.1.bn1.weight", "cnn.0. 6.1.bn1.bias", "cnn.0.6.1.bn1.running_mean", "cnn.0.6.1.bn1.running_var", "cnn.0.6.1.conv2.weight", "cnn.0.6.1.bn2.weight", "cnn.0.6.1.bn2.bias", "cnn.0.6.1.bn2.running_mean", "cnn.0.6.1.bn2.ru nning_var", "cnn.0.6.1.conv3.weight", "cnn.0.6.1.bn3.weight", "cnn.0.6.1.bn3.bias", "cnn.0.6.1.bn3.running_mean", "cnn.0.6.1.bn3.running_var", "cnn.0.6.2.conv1.weight", "cnn.0.6.2.bn1.weight", "cnn.0.6.2.bn1.bias", "cnn.0.6.2.bn1.running_mean", "cnn.0.6.2.bn1.running_var", "cnn.0.6.2.conv2.weight", "cnn.0.6.2.bn2.weight", "cnn.0.6.2.bn2.bias", "cnn.0.6.2.bn2.running_mean", "cnn.0.6.2 .bn2.running_var", "cnn.0.6.2.conv3.weight", "cnn.0.6.2.bn3.weight", "cnn.0.6.2.bn3.bias", "cnn.0.6.2.bn3.running_mean", "cnn.0.6.2.bn3.running_var", "cnn.0.6.3.conv1.weight", "cnn.0.6.3.bn1.we ight", "cnn.0.6.3.bn1.bias", "cnn.0.6.3.bn1.running_mean", "cnn.0.6.3.bn1.running_var", "cnn.0.6.3.conv2.weight", "cnn.0.6.3.bn2.weight", "cnn.0.6.3.bn2.bias", "cnn.0.6.3.bn2.running_mean", "cn n.0.6.3.bn2.running_var", "cnn.0.6.3.conv3.weight", "cnn.0.6.3.bn3.weight", "cnn.0.6.3.bn3.bias", "cnn.0.6.3.bn3.running_mean", "cnn.0.6.3.bn3.running_var", "cnn.0.6.4.conv1.weight", "cnn.0.6.4 .bn1.weight", "cnn.0.6.4.bn1.bias", "cnn.0.6.4.bn1.running_mean", "cnn.0.6.4.bn1.running_var", "cnn.0.6.4.conv2.weight", "cnn.0.6.4.bn2.weight", "cnn.0.6.4.bn2.bias", "cnn.0.6.4.bn2.running_mea n", "cnn.0.6.4.bn2.running_var", "cnn.0.6.4.conv3.weight", "cnn.0.6.4.bn3.weight", "cnn.0.6.4.bn3.bias", "cnn.0.6.4.bn3.running_mean", "cnn.0.6.4.bn3.running_var", "cnn.0.6.5.conv1.weight", "cn n.0.6.5.bn1.weight", "cnn.0.6.5.bn1.bias", "cnn.0.6.5.bn1.running_mean", "cnn.0.6.5.bn1.running_var", "cnn.0.6.5.conv2.weight", "cnn.0.6.5.bn2.weight", "cnn.0.6.5.bn2.bias", "cnn.0.6.5.bn2.runn ing_mean", "cnn.0.6.5.bn2.running_var", "cnn.0.6.5.conv3.weight", "cnn.0.6.5.bn3.weight", "cnn.0.6.5.bn3.bias", "cnn.0.6.5.bn3.running_mean", "cnn.0.6.5.bn3.running_var", "cnn.0.7.0.conv1.weigh t", "cnn.0.7.0.bn1.weight", "cnn.0.7.0.bn1.bias", "cnn.0.7.0.bn1.running_mean", "cnn.0.7.0.bn1.running_var", "cnn.0.7.0.conv2.weight", "cnn.0.7.0.bn2.weight", "cnn.0.7.0.bn2.bias", "cnn.0.7.0.b n2.running_mean", "cnn.0.7.0.bn2.running_var", "cnn.0.7.0.conv3.weight", "cnn.0.7.0.bn3.weight", "cnn.0.7.0.bn3.bias", "cnn.0.7.0.bn3.running_mean", "cnn.0.7.0.bn3.running_var", "cnn.0.7.0.down sample.0.weight", "cnn.0.7.0.downsample.1.weight", "cnn.0.7.0.downsample.1.bias", "cnn.0.7.0.downsample.1.running_mean", "cnn.0.7.0.downsample.1.running_var", "cnn.0.7.1.conv1.weight", "cnn.0.7 .1.bn1.weight", "cnn.0.7.1.bn1.bias", "cnn.0.7.1.bn1.running_mean", "cnn.0.7.1.bn1.running_var", "cnn.0.7.1.conv2.weight", "cnn.0.7.1.bn2.weight", "cnn.0.7.1.bn2.bias", "cnn.0.7.1.bn2.running_m ean", "cnn.0.7.1.bn2.running_var", "cnn.0.7.1.conv3.weight", "cnn.0.7.1.bn3.weight", "cnn.0.7.1.bn3.bias", "cnn.0.7.1.bn3.running_mean", "cnn.0.7.1.bn3.running_var", "cnn.0.7.2.conv1.weight", " cnn.0.7.2.bn1.weight", "cnn.0.7.2.bn1.bias", "cnn.0.7.2.bn1.running_mean", "cnn.0.7.2.bn1.running_var", "cnn.0.7.2.conv2.weight", "cnn.0.7.2.bn2.weight", "cnn.0.7.2.bn2.bias", "cnn.0.7.2.bn2.ru nning_mean", "cnn.0.7.2.bn2.running_var", "cnn.0.7.2.conv3.weight", "cnn.0.7.2.bn3.weight", "cnn.0.7.2.bn3.bias", "cnn.0.7.2.bn3.running_mean", "cnn.0.7.2.bn3.running_var", "cnn.1.2.weight", "c nn.1.2.bias", "cnn.1.2.running_mean", "cnn.1.2.running_var", "cnn.1.4.weight", "cnn.1.4.bias", "cnn.1.6.weight", "cnn.1.6.bias", "cnn.1.6.running_mean", "cnn.1.6.running_var", "cnn.1.8.weight", "cnn.1.8.bias", "nlp.0.module.encoder.weight", "nlp.0.module.encoder_dp.emb.weight", "nlp.0.module.rnns.0.weight_hh_l0_raw", "nlp.0.module.rnns.0.module.weight_ih_l0", "nlp.0.module.rnns.0.mod ule.weight_hh_l0", "nlp.0.module.rnns.0.module.bias_ih_l0", "nlp.0.module.rnns.0.module.bias_hh_l0", "nlp.0.module.rnns.1.weight_hh_l0_raw", "nlp.0.module.rnns.1.module.weight_ih_l0", "nlp.0.mo dule.rnns.1.module.weight_hh_l0", "nlp.0.module.rnns.1.module.bias_ih_l0", "nlp.0.module.rnns.1.module.bias_hh_l0", "nlp.0.module.rnns.2.weight_hh_l0_raw", "nlp.0.module.rnns.2.module.weight_ih _l0", "nlp.0.module.rnns.2.module.weight_hh_l0", "nlp.0.module.rnns.2.module.bias_ih_l0", "nlp.0.module.rnns.2.module.bias_hh_l0", "nlp.1.layers.0.weight", "nlp.1.layers.0.bias", "nlp.1.layers. 0.running_mean", "nlp.1.layers.0.running_var", "nlp.1.layers.2.weight", "nlp.1.layers.2.bias", "att.conv_Q.weight", "att.conv_K.weight", "att.conv_V.weight", "fc1.0.weight", "fc1.0.bias", "fc1. 0.running_mean", "fc1.0.running_var", "fc1.2.weight", "fc1.2.bias", "fc2.1.weight", "fc2.1.bias".

Unexpected key(s) in state_dict: "0.encoder.weight", "0.encoder_dp.emb.weight", "0.rnns.0.weight_hh_l0_raw", "0.rnns.0.module.weight_ih_l0", "0.rnns.0.module.weight_hh_l0", "0.rnns.0.module.bias_ih_l0", "0.rnns.0.module.bias_hh_l0", "0.rnns.1.weight_hh_l0_raw", "0.rnns.1.module.weight_ih_l0", "0.rnns.1.module.weight_hh_l0", "0.rnns.1.module.bias_ih_l0", "0.rnns.1.module.bias_hh_l0", "0.rnns.2.weight_hh_l0_raw", "0.rnns.2.module.weight_ih_l0", "0.rnns.2.module.weight_hh_l0", "0.rnns.2.module.bias_ih_l0", "0.rnns.2.module.bias_hh_l0", "1.decoder.weight", "1.decoder.bias".

It seems like there is a problem when trying to load the state_dict of the model, and whatever in the state_dict now seems only related to RNNTrainerSimple. It will be wonderful if you can offer some assitance.

Some other information

sumone-compbio commented 1 year ago

Hi, I'm stuck at the same error. Please let me know if you figured it out.