Traceback (most recent call last):
File "./tools/train_val.py", line 176, in
train(rank, local_rank, device, args)
File "./tools/train_val.py", line 67, in train
model = ClsModel(args.model_name, args.num_classes, args.is_pretrained)
File "/root/gpf/pytorch_classification/cls_models/model.py", line 31, in init
self.base_model = getattr(torchvision.models, self.model_name)(weights=ModelWeights[self.model_name])
File "/root/miniconda3/envs/pytorch_clas/lib/python3.7/site-packages/torchvision/models/resnet.py", line 277, in resnet18
kwargs)
File "/root/miniconda3/envs/pytorch_clas/lib/python3.7/site-packages/torchvision/models/resnet.py", line 260, in _resnet
model = ResNet(block, layers, kwargs)
TypeError: init() got an unexpected keyword argument 'weights'
Traceback (most recent call last): File "./tools/train_val.py", line 176, in
train(rank, local_rank, device, args)
File "./tools/train_val.py", line 67, in train
model = ClsModel(args.model_name, args.num_classes, args.is_pretrained)
File "/root/gpf/pytorch_classification/cls_models/model.py", line 31, in init
self.base_model = getattr(torchvision.models, self.model_name)(weights=ModelWeights[self.model_name])
File "/root/miniconda3/envs/pytorch_clas/lib/python3.7/site-packages/torchvision/models/resnet.py", line 277, in resnet18
kwargs)
File "/root/miniconda3/envs/pytorch_clas/lib/python3.7/site-packages/torchvision/models/resnet.py", line 260, in _resnet
model = ResNet(block, layers, kwargs)
TypeError: init() got an unexpected keyword argument 'weights'
使用的包版本: pytorch==1.8.1+cu101 torchvision==0.9.1+cu101
为什么会报上面的错误?