Skip to content
This repository was archived by the owner on Sep 21, 2020. It is now read-only.
This repository was archived by the owner on Sep 21, 2020. It is now read-only.

为什么我在替换nn.Conv2d的时候,初始化权重会报错? #33

@tianyuluan

Description

@tianyuluan

听从您的建议,我用GhostModule代替我网络中的nn.Conv2d,别的没有改动,然后测试网络,会报错如下:
Traceback (most recent call last):
File "C:/Users/luan/Downloads/YOLOv4-PyTorch-master/CSPDarknet53.py", line 184, in
model = CSPDarknet53()
File "C:/Users/luan/Downloads/YOLOv4-PyTorch-master/CSPDarknet53.py", line 154, in init
self.stem_conv = Conv(3, stem_channels, 3)
File "C:/Users/luan/Downloads/YOLOv4-PyTorch-master/CSPDarknet53.py", line 67, in init
MyConv2d(in_channels, out_channels, kernel_size, stride),
File "C:/Users/luan/Downloads/YOLOv4-PyTorch-master/CSPDarknet53.py", line 37, in init
nn.Conv2d(init_channels, new_channels, dw_size, 1, dw_size//2, groups=init_channels, bias=False),
File "C:\anaconda\lib\site-packages\torch\nn\modules\conv.py", line 338, in init
False, pair(0), groups, bias, padding_mode)
File "C:\anaconda\lib\site-packages\torch\nn\modules\conv.py", line 53, in init
self.reset_parameters()
File "C:\anaconda\lib\site-packages\torch\nn\modules\conv.py", line 56, in reset_parameters
init.kaiming_uniform
(self.weight, a=math.sqrt(5))
File "C:\anaconda\lib\site-packages\torch\nn\init.py", line 322, in kaiming_uniform_
fan = _calculate_correct_fan(tensor, mode)
File "C:\anaconda\lib\site-packages\torch\nn\init.py", line 291, in _calculate_correct_fan
fan_in, fan_out = _calculate_fan_in_and_fan_out(tensor)
File "C:\anaconda\lib\site-packages\torch\nn\init.py", line 223, in _calculate_fan_in_and_fan_out
receptive_field_size = tensor[0][0].numel()
IndexError: index 0 is out of bounds for dimension 0 with size 0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions