Closed pzz2011 closed 6 years ago
Hi, @pzz2011
You can regard conv = nn.Conv2D
as an instantiation of a convolutional layer. The self.conv1 and self.conv2 are 2 instantiations defined in the __init__
function and I am continuously reusing these two instantiations in the forward implementation (see in the for loop).
for _ in range(25):
out = self.conv2(self.relu(self.conv1(self.relu(out))))
out = torch.add(out, inputs)
If you wanna build 3 convolutional layers with different weights, you should define 3 instantiations by utilizing nn.Conv2d
:
conv1 = nn.Conv2d(xxx)
conv2 = nn.Conv2d(xxx)
conv3 = nn.Conv2d(xxx)
Hi, there, I don't find the any code to evident that the parameter is shared. Maybe becanse I don't I understand how to use the "weight shared function" of pytorch? Can u help me? thanks.