MCPcopy Index your code
hub / github.com/patrickloeber/pytorchTutorial / NeuralNet2

Class NeuralNet2

11_softmax_and_crossentropy.py:125–137  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

123
124# Multiclass problem
125class NeuralNet2(nn.Module):
126 def __init__(self, input_size, hidden_size, num_classes):
127 super(NeuralNet2, self).__init__()
128 self.linear1 = nn.Linear(input_size, hidden_size)
129 self.relu = nn.ReLU()
130 self.linear2 = nn.Linear(hidden_size, num_classes)
131
132 def forward(self, x):
133 out = self.linear1(x)
134 out = self.relu(out)
135 out = self.linear2(out)
136 # no softmax at the end
137 return out
138
139model = NeuralNet2(input_size=28*28, hidden_size=5, num_classes=3)
140criterion = nn.CrossEntropyLoss() # (applies Softmax)

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected