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

请教一点代码问题 #3

Closed
hsm1997 opened this issue Jun 4, 2021 · 0 comments
Closed

请教一点代码问题 #3

hsm1997 opened this issue Jun 4, 2021 · 0 comments

Comments

@hsm1997
Copy link

hsm1997 commented Jun 4, 2021

关于在单位阵上做卷积,单位阵里有很多0啊,局部信息不会丢失嘛,(还是我理解错了)
比如这段代码里:

def _convert_conv_to_fc(self, conv_kernel, conv_bias):

假设输入就是(1,1,3,3), groups=1, c_in=c_out=1, 就是简单地在一张(3,3)的图上做一个3x3卷积。
I = torch.eye(9).repeat(1,1).reshape(9,1,3,3)
I = tensor([[[[1., 0., 0.],
[0., 0., 0.],
[0., 0., 0.]]],
[[[0., 1., 0.],
[0., 0., 0.],
[0., 0., 0.]]],
[[[0., 0., 1.],
[0., 0., 0.],
[0., 0., 0.]]],
[[[0., 0., 0.],
[1., 0., 0.],
[0., 0., 0.]]],
[[[0., 0., 0.],
[0., 1., 0.],
[0., 0., 0.]]],
[[[0., 0., 0.],
[0., 0., 1.],
[0., 0., 0.]]],
[[[0., 0., 0.],
[0., 0., 0.],
[1., 0., 0.]]],
[[[0., 0., 0.],
[0., 0., 0.],
[0., 1., 0.]]],
[[[0., 0., 0.],
[0., 0., 0.],
[0., 0., 1.]]]])

在这个上面做卷积,I的形状是(9,1,3,3),每个(3,3)中只有一个值不为0,卷积后reshape回去,也只有对角元上不为0,这样做(9,9)x(9,1)的矩阵乘的话,相当与给(3,3)里的每一个元素乘了一个单独的值,也不是卷积吧。

@hsm1997 hsm1997 closed this as completed Jun 4, 2021
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