我在salience_detr.py中的 class SalienceDETR(DNDETRDetector): 类 加入了
self.Re_Weight = WeightRefactor(sample_num),使用resnet50 backbone可以训练,但是swin_l 会报错:
`[2024-11-11 20:07:56 det.models.backbones.base_backbone]: Backbone architecture: swin_l
WARNING [2024-11-11 20:08:04 det.util.utils]: The model and loaded state dict do not match exactly
WARNING [2024-11-11 20:08:04 det.util.utils]: Size mismatch keys: head.weight, head.bias
+-------------+----------------+---------------------+
| key name | shape in model | shape in state dict |
+-------------+----------------+---------------------+
| head.weight | (1000, 1536) | (21841, 1536) |
+-------------+----------------+---------------------+
| head.bias | (1000,) | (21841,) |
+-------------+----------------+---------------------+
Traceback (most recent call last):
File "/data/lost+found/python project/Salience-DETR/main.py", line 206, in
train()
File "/data/lost+found/python project/Salience-DETR/main.py", line 123, in train
model = Config(cfg.model_path).model
File "/data/lost+found/python project/Salience-DETR/util/lazy_load.py", line 24, in init
exec(code, name_space)
File "", line 97, in
File "/data/lost+found/python project/Salience-DETR/models/detectors/salience_detr.py", line 355, in init
self.Re_Weight = WeightRefactor(sample_num)
File "/data/lost+found/python project/Salience-DETR/models/detectors/salience_detr.py", line 52, in init
self.layer1 = nn.Linear(sample_num sample_num, 1, bias=False)
TypeError: unsupported operand type(s) for : 'NoneType' and 'NoneType'`
同样的,focalnet也在同样的部分出现报错
[2024-11-11 21:16:25 det.models.backbones.base_backbone]: Backbone architecture: focalnet_large_lrf_fl4 WARNING [2024-11-11 21:16:31 det.util.utils]: The model and loaded state dict do not match exactly WARNING [2024-11-11 21:16:31 det.util.utils]: Unexpected keys: norm.weight, norm.bias, head.weight, head.bias 。 。 。 TypeError: unsupported operand type(s) for *: 'NoneType' and 'NoneType'
Question
我在salience_detr.py中的
class SalienceDETR(DNDETRDetector):
类 加入了self.Re_Weight = WeightRefactor(sample_num)
,使用resnet50 backbone可以训练,但是swin_l 会报错:`[2024-11-11 20:07:56 det.models.backbones.base_backbone]: Backbone architecture: swin_l WARNING [2024-11-11 20:08:04 det.util.utils]: The model and loaded state dict do not match exactly WARNING [2024-11-11 20:08:04 det.util.utils]: Size mismatch keys: head.weight, head.bias +-------------+----------------+---------------------+ | key name | shape in model | shape in state dict | +-------------+----------------+---------------------+ | head.weight | (1000, 1536) | (21841, 1536) | +-------------+----------------+---------------------+ | head.bias | (1000,) | (21841,) | +-------------+----------------+---------------------+
Traceback (most recent call last): File "/data/lost+found/python project/Salience-DETR/main.py", line 206, in
train()
File "/data/lost+found/python project/Salience-DETR/main.py", line 123, in train
model = Config(cfg.model_path).model
File "/data/lost+found/python project/Salience-DETR/util/lazy_load.py", line 24, in init
exec(code, name_space)
File "", line 97, in
File "/data/lost+found/python project/Salience-DETR/models/detectors/salience_detr.py", line 355, in init
self.Re_Weight = WeightRefactor(sample_num)
File "/data/lost+found/python project/Salience-DETR/models/detectors/salience_detr.py", line 52, in init
self.layer1 = nn.Linear(sample_num sample_num, 1, bias=False)
TypeError: unsupported operand type(s) for : 'NoneType' and 'NoneType'`
同样的,focalnet也在同样的部分出现报错
[2024-11-11 21:16:25 det.models.backbones.base_backbone]: Backbone architecture: focalnet_large_lrf_fl4 WARNING [2024-11-11 21:16:31 det.util.utils]: The model and loaded state dict do not match exactly WARNING [2024-11-11 21:16:31 det.util.utils]: Unexpected keys: norm.weight, norm.bias, head.weight, head.bias 。 。 。 TypeError: unsupported operand type(s) for *: 'NoneType' and 'NoneType'
请问这个问题是什么原因?
Additional
No response