import torch.nn as nn
model = nn.Sequential(
nn.Conv2d(in_channels=3,out_channels=32,kernel_size=7,stride=1,bias=False),
nn.ReLU(inplace=True),
nn.BatchNorm2d(num_features=32,affine=True),
nn.MaxPool2d(kernel_size=2,stride=2)
)
for key in model.state_dict():
value = model.state_dict().get(key)
print(key, value.size())
model = MyNewInceptionModel()
model.load_state_dict(param_dict)
______ __ | Torch7
/_ __/__ ________/ / | Scientific computing for Lua.
/ / / _ \/ __/ __/ _ \ | Type ? for help
/_/ \___/_/ \__/_//_/ | https://github.com/torch
th> model = nn.Sequential()
th> model:add(nn.SpatialConvolution(3, 16, 7, 7, 2, 2, 1, 1))
nn.Sequential {
[input -> (1) -> output]
(1): nn.SpatialConvolution(3 -> 16, 7x7, 2,2, 1,1)
}
th> model:add(nn.ReLU())
nn.Sequential {
[input -> (1) -> (2) -> output]
(1): nn.SpatialConvolution(3 -> 16, 7x7, 2,2, 1,1)
(2): nn.ReLU
}
th> model
nn.Sequential {
[input -> (1) -> (2) -> output]
(1): nn.SpatialConvolution(3 -> 16, 7x7, 2,2, 1,1)
(2): nn.ReLU
}
th> print(#model.modules)
2
th> model.modules[1].kW
7
th> model.modules[1].kH
7
th> model.modules[1].weight
(1,1,.,.) =
0.01 *
6.2457 -4.3545 4.7430 4.8547 -5.9223 3.3388 0.7862
-3.3725 -2.0295 -0.3997 7.7973 -5.2516 8.1476 -6.4627
2.4958 0.2896 6.2000 -4.9034 -7.7588 -5.1510 -3.8102
2.9991 -4.2541 -1.1643 -4.1169 1.4616 0.5252 0.9619
-5.8441 -1.3345 -3.3810 7.3973 -4.3998 4.8422 0.0513
-2.2906 6.6245 -0.5288 -6.3062 7.6088 -4.0588 0.0588
-0.2463 5.1402 3.0234 -2.9900 2.6643 -5.9465 -2.9145
....
[torch.DoubleTensor of size 16x3x7x7]
th> model.modules[1].bias
0.01 *
-5.4751
-4.5497
-5.9375
-7.4779
1.1394
-7.3193
0.1563
7.2150
1.8851
-2.9125
4.1081
-3.5006
-0.8639
-2.4370
3.5407
1.8183
[torch.DoubleTensor of size 16]
You get the idea.