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

Method __init__

beginner_source/examples_nn/polynomial_module.py:18–27  ·  view source on GitHub ↗

In the constructor we instantiate four parameters and assign them as member parameters.

(self)

Source from the content-addressed store, hash-verified

16
17class Polynomial3(torch.nn.Module):
18 def __init__(self):
19 """
20 In the constructor we instantiate four parameters and assign them as
21 member parameters.
22 """
23 super().__init__()
24 self.a = torch.nn.Parameter(torch.randn(()))
25 self.b = torch.nn.Parameter(torch.randn(()))
26 self.c = torch.nn.Parameter(torch.randn(()))
27 self.d = torch.nn.Parameter(torch.randn(()))
28
29 def forward(self, x):
30 """

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected