FcaNet icon indicating copy to clipboard operation
FcaNet copied to clipboard

关于 the L73-L83 in model/layer.py 中learnable tensor的问题

Open mapleTan1113 opened this issue 2 years ago • 2 comments

你好!

在使用

# learnable DCT init
self.register_parameter('weight', self.get_dct_filter(height, width, mapper_x, mapper_y, channel))
# learnable random init
self.register_parameter('weight', torch.rand(channel, height, width))

这两种初始化方法时,会出现以下bug:

TypeError: cannot assign 'torch.FloatTensor' object to parameter 'weight' (torch.nn.Parameter or None required)

help plz :)

mapleTan1113 avatar Mar 25 '22 04:03 mapleTan1113

btw,我只是简单将其改为

self.register_parameter('weight', nn.Parameter(self.get_dct_filter(height, width, mapper_x, mapper_y, channel)))

不知道是否与作者的原意等价😂

mapleTan1113 avatar Mar 25 '22 04:03 mapleTan1113

等价的,或是直接使用:

self.weight = nn.Parameter(self.get_dct_filter(height, width, mapper_x, mapper_y, channel))

Asthestarsfalll avatar Nov 08 '22 07:11 Asthestarsfalll