-
-
Save rafalpronko/ce0f4ec5a7676dc50f1d8dfc0de2c069 to your computer and use it in GitHub Desktop.
This file contains 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
class NeuralNet(nn.Module): | |
def __init__(self, num_of_class): | |
super(NeuralNet, self).__init__() | |
self.layer1 = nn.Sequential( | |
nn.Conv2d(1, 16, kernel_size=5, stride=1, padding=2), | |
nn.BatchNorm2d(16), | |
nn.ReLU(), | |
nn.MaxPool2d(kernel_size=2, stride=2)) | |
self.layer2 = nn.Sequential( | |
nn.Conv2d(16, 32, kernel_size=5, stride=1, padding=2), | |
nn.BatchNorm2d(32), | |
nn.ReLU(), | |
nn.MaxPool2d(kernel_size=2, stride=2)) | |
self.fc = nn.Linear(7 * 7 * 32, num_of_class) | |
def forward(self, x): | |
out = self.layer1(x) | |
out = self.layer2(out) | |
out = out.reshape(out.size(0), -1) | |
out = self.fc(out) | |
return out |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment