Last active
September 8, 2020 07:14
-
-
Save ttchengab/ea73aae0573c64c4c48a9b5d1317329a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Creating a simple network | |
class LeNet5(torch.nn.Module): | |
def __init__(self): | |
super(LeNet5, self).__init__() | |
self.conv1 = torch.nn.Conv2d(1, 6, 5, padding=2) | |
self.conv2 = torch.nn.Conv2d(6, 16, 5) | |
self.fc1 = nn.Linear(16*5*5, 120) | |
self.fc2 = nn.Linear(120, 84) | |
self.fc3 = nn.Linear(84, 10) | |
def forward(self, x): | |
x = F.relu(self.conv1(x)) | |
x = F.max_pool2d(x, 2) | |
x = F.relu(self.conv2(x)) | |
x = F.max_pool2d(x, 2) | |
x = x.view(-1, 16*5*5) | |
x = F.relu(self.fc1(x)) | |
x = F.relu(self.fc2(x)) | |
x = self.fc3(x) | |
return F.log_softmax(x,dim=-1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment