yjxiong / tsn-pytorch

Temporal Segment Networks (TSN) in PyTorch
BSD 2-Clause "Simplified" License
1.06k stars 311 forks source link

AttributeError: 'BNInception' object has no attribute 'fc #98

Open yhc1994 opened 4 years ago

yhc1994 commented 4 years ago

Hi anyone met this error? Anyone know how to solve this?

(base) james@james-MS-7C00:~/tsn-pytorch$ python main.py ucf101 RGB ucf101_rgb_train_list ucf101_rgb_val_list --arch BNInception --num_segments 3 --gd 20 --lr 0.001 --lr_steps 30 60 --epochs 80 -b 128 -j 8 --dropout 0.8 --snapshot_pref ucf101bninception

Initializing TSN with base model: BNInception. TSN Configurations: input_modality: RGB num_segments: 3 new_length: 1 consensus_module: avg dropout_ratio: 0.8

Traceback (most recent call last): File "main.py", line 301, in main() File "main.py", line 35, in main consensus_type=args.consensus_type, dropout=args.dropout, partial_bn=not args.no_partialbn) File "/home/james/tsn-pytorch/models.py", line 41, in init feature_dim = self._prepare_tsn(num_class) File "/home/james/tsn-pytorch/models.py", line 62, in _prepare_tsn feature_dim = getattr(self.base_model, self.base_model.last_layer_name).in_features File "/home/james/anaconda3/lib/python3.7/site-packages/torch/nn/modules/module.py", line 585, in getattr type(self).name, name)) AttributeError: 'BNInception' object has no attribute 'fc'

Ego-J commented 4 years ago

Maybe your model's last layer id is not 'fc' and you should check it. Where did you get the BNInception pretrained model, I have seen two BNInception pretrained models with different last layer id.

yhc1994 commented 4 years ago

Maybe your model's last layer id is not 'fc' and you should check it. Where did you get the BNInception pretrained model, I have seen two BNInception pretrained models with different last layer id.

Hi Egoist, how did you check the last layer id of BNInception pretrained models? I can see it is unreadable if I opened it in notepad++