Hello, I have the following model:
class CovNet(nn.Module):
def __init__(self, imageSize):
super(CovNet, self).__init__()
kernel = (3,3)
self.conv1 = nn.Conv2d(in_channels = 1, out_channels = 3, kernel_size = kernel)
wOut = self.parametersCalculator(imageSize,3,0,1,1) #Calculate size of data after conv
wOut = self.parametersCalculator(wOut,2,0,2,1) #Calculate size of data after maxpool
self.fc2 = nn.Linear(3 * wOut * wOut, 120)
self.fc3 = nn.Linear(120, 60)
self.fc4 = nn.Linear(60, 10)
def forward(self, x):
x = F.max_pool2d(F.relu(self.conv1(x)), 2)
x = x.view(-1, self.num_flat_features(x))
x = F.relu(self.fc2(x))
x = F.relu(self.fc3(x))
x = self.fc4(x)
return x
def num_flat_features(self, x):
print(x.size())
size = x.size()[1:] # all dimensions except the batch dimension
num_features = 1
for s in size:
num_features *= s
return num_features
def parametersCalculator(self,W,K,P,S,D):
return int((W+2*P-D*(K-1)-1)/S + 1)
And I am trying to get the parameters of this model. To this end I wrote this line:
params = list(model.parameters())
This variable is an array with 8 length with the following shapes:
params[0].shape --> (3,1,3,3)
params[1].shape --> (3)
params[2].shape --> (120,507)
params[3].shape --> (120)
params[4].shape --> (60,120)
params[5].shape --> (60)
params[6].shape --> (10, 60)
params[7].shape --> (10)
The image size is 28 by 28.
Can someone explain to me the shapes of the params variable, i dont seem to understand what are the shapes of params 1,3,5 and 6? Are theese the biases?
Thank you in advance!