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

Method __init__

intermediate_source/visualizing_gradients_tutorial.py:67–83  ·  view source on GitHub ↗
(self, in_size=28*28, hidden_size=128,
                 out_size=10, num_layers=3, batchnorm=False)

Source from the content-addressed store, hash-verified

65class Net(nn.Module):
66 """Define a network that has num_layers of linear->norm->sigmoid transformations"""
67 def __init__(self, in_size=28*28, hidden_size=128,
68 out_size=10, num_layers=3, batchnorm=False):
69 super().__init__()
70 if batchnorm is False:
71 norm_layer = nn.Identity
72 else:
73 norm_layer = nn.BatchNorm1d
74
75 layers = []
76 layers.append(fc_layer(in_size, hidden_size, norm_layer))
77
78 for i in range(num_layers-1):
79 layers.append(fc_layer(hidden_size, hidden_size, norm_layer))
80
81 layers.append(nn.Linear(hidden_size, out_size))
82
83 self.layers = nn.Sequential(*layers)
84
85 def forward(self, x):
86 x = torch.flatten(x, 1)

Callers

nothing calls this directly

Calls 1

fc_layerFunction · 0.85

Tested by

no test coverage detected