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

Method forward

beginner_source/blitz/neural_networks_tutorial.py:58–84  ·  view source on GitHub ↗
(self, input)

Source from the content-addressed store, hash-verified

56 self.fc3 = nn.Linear(84, 10)
57
58 def forward(self, input):
59 # Convolution layer C1: 1 input image channel, 6 output channels,
60 # 5x5 square convolution, it uses RELU activation function, and
61 # outputs a Tensor with size (N, 6, 28, 28), where N is the size of the batch
62 c1 = F.relu(self.conv1(input))
63 # Subsampling layer S2: 2x2 grid, purely functional,
64 # this layer does not have any parameter, and outputs a (N, 6, 14, 14) Tensor
65 s2 = F.max_pool2d(c1, (2, 2))
66 # Convolution layer C3: 6 input channels, 16 output channels,
67 # 5x5 square convolution, it uses RELU activation function, and
68 # outputs a (N, 16, 10, 10) Tensor
69 c3 = F.relu(self.conv2(s2))
70 # Subsampling layer S4: 2x2 grid, purely functional,
71 # this layer does not have any parameter, and outputs a (N, 16, 5, 5) Tensor
72 s4 = F.max_pool2d(c3, 2)
73 # Flatten operation: purely functional, outputs a (N, 400) Tensor
74 s4 = torch.flatten(s4, 1)
75 # Fully connected layer F5: (N, 400) Tensor input,
76 # and outputs a (N, 120) Tensor, it uses RELU activation function
77 f5 = F.relu(self.fc1(s4))
78 # Fully connected layer F6: (N, 120) Tensor input,
79 # and outputs a (N, 84) Tensor, it uses RELU activation function
80 f6 = F.relu(self.fc2(f5))
81 # Fully connected layer OUTPUT: (N, 84) Tensor input, and
82 # outputs a (N, 10) Tensor
83 output = self.fc3(f6)
84 return output
85
86
87net = Net()

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected