Hi I’m running the code snippet below.
class LFBlock(nn.Module):
def __init__(self, kernel_size=(1,1,1), block_shape=(32,32,32)):
super(LFBlock,self).__init__()
self.block_shape = block_shape
self.conv = nn.Conv3d(1,1, kernel_size=kernel_size, stride=1, padding=0, bias=True)
def forward(self, x):
x1 = x[:,0][:,None]
x2 = x[:,1][:,None]
x3 = x[:,2][:,None]
x4 = x[:,3][:,None]
x1 = self.conv(x1)
print('x1 | convweight=', self.conv.weight.data)
x2 = self.conv(x2)
print('x2 | convweight=', self.conv.weight.data)
x3 = self.conv(x3)
print('x3 | convweight=', self.conv.weight.data)
x4 = self.conv(x4)
print('x4 | convweight=', self.conv.weight.data)
The print outputs of this code snippet is:
x1 | convweight= tensor([[[[[-0.2251]]]]])
x2 | convweight= tensor([[[[[-0.2251]]]]])
x3 | convweight= tensor([[[[[-0.2251]]]]])
x4 | convweight= tensor([[[[[-0.2251]]]]])
Where the weights of each conv is the same. This is a smaller scale testing of a model where I’m running lots of small convolutions ~16 for a single pass. Instead of defining 16 individual conv layers, I was thinking I could just reuse one. Where am I going wrong?