There is a network that has completed training with VGG16. It was saved using torch.save.
e.g.
state = {
'net': net.module if use_cuda else net,
'acc': acc,
}
if not os.path.isdir('checkpoint'):
os.mkdir('checkpoint')
torch.save(state, './checkpoint/ckpt_20190312_cifar10_vgg16.t7')
best_acc = acc
I would like to implement VGG16_v2 with the same structure as VGG16 and using other convolution operations.
At this time, I want to import the weight / bias values of the pretrained VGG16.
Once I have implemented the following:
checkpoint = torch.load('./checkpoint/ckpt_20190312_cifar10_vgg16.t7') # Load your own neural network models
net = checkpoint['net']
model = VGG16_v2.VGG()
model.load_state_dict(net, strict=False)
When I implemented this, I got the following error.
Traceback (most recent call last):
File “main_20190325_cifar10_vgg16_alpha_training_v1.py”, line 75, in
model.load_state_dict(net, strict=False)
File “/home/mhha/.conda/envs/pytorchmh/lib/python3.6/site-packages/torch/nn/modules/module.py”, line 695, in load_state_dict
state_dict = state_dict.copy()
File “/home/mhha/.conda/envs/pytorchmh/lib/python3.6/site-packages/torch/nn/modules/module.py”, line 532, in getattr
type(self).name, name))
AttributeError: ‘VGG’ object has no attribute ‘copy’
How can I solve this problem?