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

Method forward

beginner_source/examples_nn/polynomial_module.py:29–35  ·  view source on GitHub ↗

In the forward function we accept a Tensor of input data and we must return a Tensor of output data. We can use Modules defined in the constructor as well as arbitrary operators on Tensors.

(self, x)

Source from the content-addressed store, hash-verified

27 self.d = torch.nn.Parameter(torch.randn(()))
28
29 def forward(self, x):
30 """
31 In the forward function we accept a Tensor of input data and we must return
32 a Tensor of output data. We can use Modules defined in the constructor as
33 well as arbitrary operators on Tensors.
34 """
35 return self.a + self.b * x + self.c * x ** 2 + self.d * x ** 3
36
37 def string(self):
38 """

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected