3.3.4 TypeError: 'LinearNet' object is not subscriptable
Moshiii opened this issue · comments
Moshi Wei commented
Hi,
thanks for the hard work!
I am trying this part but it gives me error:
TypeError Traceback (most recent call last)
in
----> 1 init.normal_(net[0].weight, mean=0, std=0.01)
2 init.constant_(net[0].bias, val=0)
TypeError: 'LinearNet' object is not subscriptable
this is the linearnet:
class LinearNet(nn.Module):
def init(self, n_feature):
super(LinearNet, self).init()
self.linear = nn.Linear(n_feature, 1)
def forward(self, x):
y = self.linear(x)
return y
net = LinearNet(num_inputs)
print(net)
my Torch version is 1.5.1