I constructed the nn model using itorch notebook.
model = nn.Sequential()
model:add(nn.Reshape(ninputs))
model:add(nn.Linear(ninputs,noutputs))
Input data to the model
output = model:forward(input)
Then, I print the model and got this.
print(model)
nn.Sequential {
[input -> (1) -> (2) -> output]
(1): nn.Reshape(3072)
(2): nn.Linear(3072 -> 10)
}
{
gradInput : DoubleTensor - empty
modules :
{
1 :
nn.Reshape(3072)
{
_input : DoubleTensor - empty
nelement : 3072
train : true
output : DoubleTensor - size: 3072
gradInput : DoubleTensor - empty
size : LongStorage - size: 1
_gradOutput : DoubleTensor - empty
batchsize : LongStorage - size: 2
}
2 :
nn.Linear(3072 -> 10)
{
gradBias : DoubleTensor - size: 10
weight : DoubleTensor - size: 10x3072
train : true
bias : DoubleTensor - size: 10
gradInput : DoubleTensor - empty
gradWeight : DoubleTensor - size: 10x3072
output : DoubleTensor - size: 10
}
}
train : true
output : DoubleTensor - size: 10
}
how to read the weight in nn.linear ?
Thanks in advance.
Oh, it is similar to php
model.modules[2].weight
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With