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

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

Open
mapleTan1113 opened this issue Mar 25, 2022 · 2 comments
Open

Comments

@mapleTan1113
Copy link

mapleTan1113 commented Mar 25, 2022

你好!

在使用

# 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
Copy link
Author

btw,我只是简单将其改为

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

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

@Asthestarsfalll
Copy link

等价的,或是直接使用:

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

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

2 participants