Skip to content

Instantly share code, notes, and snippets.

@omarsar
Created August 31, 2019 13:57
Show Gist options
  • Save omarsar/3d78ae4983f534dc9dbccbd1ed639e9f to your computer and use it in GitHub Desktop.
Save omarsar/3d78ae4983f534dc9dbccbd1ed639e9f to your computer and use it in GitHub Desktop.
## the model
class MyModel(nn.Module):
def __init__(self):
super(MyModel, self).__init__()
self.d1 = nn.Linear(28 * 28, 128)
self.dropout = nn.Dropout(p=0.2)
self.d2 = nn.Linear(128, 10)
def forward(self, x):
x = x.flatten(start_dim = 1)
x = self.d1(x)
x = F.relu(x)
x = self.dropout(x)
logits = self.d2(x)
out = F.softmax(logits, dim=1)
return out
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment