Skip to content

Instantly share code, notes, and snippets.

@bumie-e
Created February 7, 2021 12:41
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 bumie-e/ba14e4f37ac6356038bb4330df352902 to your computer and use it in GitHub Desktop.
Save bumie-e/ba14e4f37ac6356038bb4330df352902 to your computer and use it in GitHub Desktop.
import torch
import torch.nn as nn
class NeuralNet(nn.Module):
def __init__(self, input_size, hidden_size, num_classes):
super(NeuralNet, self).__init__()
self.l1 = nn.Linear(input_size, hidden_size)
self.l2 = nn.Linear(hidden_size, hidden_size)
self.l3 = nn.Linear(hidden_size, num_classes)
self.relu = nn.ReLU()
def forward(self, x):
out = self.l1(x)
out = self.relu(out)
out = self.l2(out)
out = self.relu(out)
out = self.l3(out)
# no activation and no softmax at the end
return out
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment