MCPcopy Create free account
hub / github.com/pytorch/tutorials / forward

Method forward

intermediate_source/per_sample_grads.py:34–45  ·  view source on GitHub ↗
(self, x)

Source from the content-addressed store, hash-verified

32 self.fc2 = nn.Linear(128, 10)
33
34 def forward(self, x):
35 x = self.conv1(x)
36 x = F.relu(x)
37 x = self.conv2(x)
38 x = F.relu(x)
39 x = F.max_pool2d(x, 2)
40 x = torch.flatten(x, 1)
41 x = self.fc1(x)
42 x = F.relu(x)
43 x = self.fc2(x)
44 output = F.log_softmax(x, dim=1)
45 return output
46
47def loss_fn(predictions, targets):
48 return F.nll_loss(predictions, targets)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected