????
?????????PyTorch?????????????????????????????????????????????
PyTorch??????
PyTorch??????TensorFlow?????????????????????????????nn.Module???????????Convolutional Neural Network (CNN)???
class Net(nn.Module):def __init__(self): super().__init__() self.conv1 = nn.Conv2d(1, 6, 5) self.conv2 = nn.Conv2d(6, 16, 5)def forward(self, x): x = F.max_pool2d(F.relu(self.conv1(x)), 2) x = F.max_pool2d(F.relu(self.conv2(x)), 2) return x ????????????????__init__???????forward??__init__????????????forward??????????????
?????????
???????????????????????????????????????????PyTorch??????????????????????????
?????????
????????????????????????????????????????????MSELoss???????CrossEntropyLoss?????????
compute_loss = nn.MSELoss()