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

Method __init__

beginner_source/examples_nn/dynamic_net.py:17–26  ·  view source on GitHub ↗

In the constructor we instantiate five parameters and assign them as members.

(self)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected