Hey there, I have built a neural Network to classify MNIST but there’s an error below is my code
depth=[4,8]
class ConvNet(nn.Module):
def init(self):
super(ConvNet,self).init() ?
self.conv1=nn.Conv2d(1,4,5,padding=2)
self.blocks=nn.ModuleList(block)
self.pool=nn.MaxPool2d(2,2)
#No2.Convolution
self.conv2=nn.Conv2d(depth[0],depth[1],5,padding=2)
self.fc1=nn.Linear(image_size//4image_size//4depth[1],512)#int division
self.fc2=nn.Linear(512,num_classes)
def forward(self,x):
x=self.conv1(x)
x=F.relu(x)
x=self.pool(x)
x=self.conv2(x)
x=F.relu(x)
x=self.pool(x)
x=x.view(-1,image_size//4image_size//4depth[1])
x=F.relu(self.fc1(x))
x=F.dropout(x,training=self.training)
x=self.fc2(x)
x=F.log_softmax(x,dim=1)
return x
def retreive_features(self,x):#get_features maps
features_map1=F.relu(self.conv1(x))
x=self.pool(feature_map1)
features_map2=F.relu(self.conv2(x))
return (features_map1,features_map2)
net=ConvNet().cuda()
optimizer=optim.SGD(params=net.parameters(),lr=0.001,momentum=0.9)
error raise:optimizer got an empty parameter list
How can i do?