我寫(xiě)的沒(méi)問(wèn)題和老師的一樣但是print出來(lái)的是Net()
class Net(nn.Module):
? ? def _init_(self): #神經(jīng)網(wǎng)絡(luò)結(jié)構(gòu),輸入數(shù)據(jù) 1*32*32
? ? ? ? super(Net,self)._init_()
? ? ? ? #conve
? ? ? ? self.conv1=nn.Conv2d(1,6,3) #輸入配道1,輸出判道6,卷積3*3
? ? ? ? #第2層
? ? ? ? self.conv2=nn.Conv2d(6,16,3)#輸入配道6,輸出判道16,卷積3*3
? ? ? ? #full connect
? ? ? ? self.fc1=nn.Linear(16*28*28,512)
? ? ? ? self.fc2=nn.Linear(512,64)
? ? ? ? self.fc3=nn.Linear(64,2)
? ? ? ??
? ? def forward(self,x):
? ? ? ? x = self.conv1(x)
? ? ? ? x= F.relu(x)
? ? ? ??
? ? ? ? x=self.conv2(x)
? ? ? ? x=F.relu(x)
? ? ? ??
? ? ? ? x= x.view(-1,16*28*28)
? ? ? ? x=self.fc1(x)
? ? ? ? x=F.relu(x)
? ? ? ??
? ? ? ? x=self.fc2(x)
? ? ? ? x=F.relu(x)
? ? ? ??
? ? ? ? x=self.fc3(x)
? ? ? ? return x
? ? ? ??
2021-03-30
init那里,前后都是兩個(gè)下滑線