Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: __init__() got an unexpected keyword argument 'weights' #51

Closed
gpf1991 opened this issue Apr 28, 2023 · 3 comments
Closed

TypeError: __init__() got an unexpected keyword argument 'weights' #51

gpf1991 opened this issue Apr 28, 2023 · 3 comments

Comments

@gpf1991
Copy link

gpf1991 commented Apr 28, 2023

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

为什么会报上面的错误?

@gpf1991 gpf1991 closed this as completed May 4, 2023
@gpf1991
Copy link
Author

gpf1991 commented May 4, 2023

已解决

@wuhaowuhao
Copy link

请问这个报错是怎么解决的?

@Grimm-L
Copy link

Grimm-L commented Oct 16, 2023

请问咋解决的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants