按照代碼輸入后print(net)輸出與老師輸出的不一樣
class Net(nn.Module):
? ? def __int__(self):#定義神經網絡結構,輸入數據結構為 1x32x32
? ? ? ? super(Net,self).__int__()#兩個卷積層,三個全連接層
? ? ? ??
? ? ? ? #第一層(卷積層)
? ? ? ? self.convl=nn.Conv2d(1,6,3)?
? ? ? ? #第二層(卷積層)
? ? ? ? self.conv2=nn.Conv2d(6,16,3)
? ? ? ? #第三層(全連接層)
? ? ? ? self.fc1=nn.Linaer(16*28*28,512)
? ? ? ? #第四層(全連接層)
? ? ? ? self.fc2=nn.Linear(512, 64)
? ? ? ? #第五層(全連接層)
? ? ? ? self.fc3=nn.Linaer(64, 2)
? ? def forward(self, x): #定義數據流向
? ? ? ? x=self.convl(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)
? ? ? ? x=F.relu(x)
? ? ? ??
? ? ? ? return x
2020-02-29
第一層的conv1打成了convl
第三層的Lineari打成了Linaer
第五層的Linear打成了Linaer