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: forward() got an unexpected keyword argument 'weight' #3815

Open
llyyccccc opened this issue Nov 18, 2024 · 1 comment
Open

TypeError: forward() got an unexpected keyword argument 'weight' #3815

llyyccccc opened this issue Nov 18, 2024 · 1 comment

Comments

@llyyccccc
Copy link

当使用单个损失如 CrossEntropyLoss或者diceloss时不会报错。但如果同时使用,则会报错:Traceback (most recent call last):
File "train.py", line 242, in
main()
File "train.py", line 238, in main
meta=meta)
File "/home/deeplearning/MetaSeg-main/mmseg/apis/train.py", line 194, in train_segmentor
runner.run(data_loaders, cfg.workflow)
File "/home/deeplearning/anaconda3/envs/lyc/lib/python3.7/site-packages/mmcv/runner/iter_based_runner.py", line 144, in run
iter_runner(iter_loaders[i], **kwargs)
File "/home/deeplearning/anaconda3/envs/lyc/lib/python3.7/site-packages/mmcv/runner/iter_based_runner.py", line 64, in train
outputs = self.model.train_step(data_batch, self.optimizer, **kwargs)
File "/home/deeplearning/anaconda3/envs/lyc/lib/python3.7/site-packages/mmcv/parallel/data_parallel.py", line 77, in train_step
return self.module.train_step(*inputs[0], **kwargs[0])
File "/home/deeplearning/MetaSeg-main/mmseg/models/segmentors/base.py", line 138, in train_step
losses = self(**data_batch)
File "/home/deeplearning/anaconda3/envs/lyc/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1130, in _call_impl
return forward_call(*input, **kwargs)
File "/home/deeplearning/anaconda3/envs/lyc/lib/python3.7/site-packages/mmcv/runner/fp16_utils.py", line 116, in new_func
return old_func(*args, **kwargs)
File "/home/deeplearning/MetaSeg-main/mmseg/models/segmentors/base.py", line 108, in forward
return self.forward_train(img, img_metas, **kwargs)
File "/home/deeplearning/MetaSeg-main/mmseg/models/segmentors/encoder_decoder.py", line 144, in forward_train
gt_semantic_seg)
File "/home/deeplearning/MetaSeg-main/mmseg/models/segmentors/encoder_decoder.py", line 88, in _decode_head_forward_train
self.train_cfg)
File "/home/deeplearning/MetaSeg-main/mmseg/models/decode_heads/decode_head.py", line 192, in forward_train
losses = self.losses(seg_logits, gt_semantic_seg)
File "/home/deeplearning/anaconda3/envs/lyc/lib/python3.7/site-packages/mmcv/runner/fp16_utils.py", line 205, in new_func
return old_func(*args, **kwargs)
File "/home/deeplearning/MetaSeg-main/mmseg/models/decode_heads/decode_head.py", line 237, in losses
ignore_index=self.ignore_index)
File "/home/deeplearning/anaconda3/envs/lyc/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1130, in _call_impl
return forward_call(*input, **kwargs)
TypeError: forward() got an unexpected keyword argument 'weight'

@llyyccccc
Copy link
Author

版本:mmcv-full==1.6.0

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

1 participant