Skip to content

Instantly share code, notes, and snippets.

@rafalpronko
Created February 11, 2019 05:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rafalpronko/ce0f4ec5a7676dc50f1d8dfc0de2c069 to your computer and use it in GitHub Desktop.
Save rafalpronko/ce0f4ec5a7676dc50f1d8dfc0de2c069 to your computer and use it in GitHub Desktop.
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