if you want to see the parameters of the networks you can know that
the parameters of network is a generator instance.
class Net(nn.Module):
def __init__(self):
super(Net,self).__init__()
self.l1=nn.Linear(1,4)
# self.relu=nn.ReLU()
self.l2=nn.Linear(4,2)
def forward(self,x):
x=self.l1(x)
x=self.relu(x)
x=self.l2(x)
return x
the architecture is above
if you execute this command
net=Net()
print(net.parameters())
for i in net.parameters():
print(i)
#<generator object Module.parameters at 0x7f8df0c6af68>
the result is like this
Parameter containing:
tensor([[ 0.2810],
[ 0.7666],
[ 0.7390],
[-0.8258]], requires_grad=True)
1
Parameter containing:
tensor([ 0.2996, 0.0812, -0.7105, -0.7501], requires_grad=True)
2
Parameter containing:
tensor([[-0.2219, 0.2144, 0.2282, 0.4191],
[ 0.0240, -0.0262, -0.4772, 0.2216]], requires_grad=True)
3
Parameter containing:
tensor([0.4966, 0.4801], requires_grad=True)
4
the first tensor is the first layer which is 41
the second tensor is the bias of the the first layer so it’s also 41
the second tensor is the second layer which is 42
the second layer is the bias of the second layer which is 12
to be continued