I'm trying to convert CNN Keras model for Emotion Recognition using FER2013 dataset to PyTorch model and I have following error:
Traceback (most recent call last):
File "VGG.py", line 112, in <module>
transfer.keras_to_pytorch(keras_network, pytorch_network)
File "/home/eorg/NeuralNetworks/user/Project/model/nntransfer.py", line 121, in keras_to_pytorch
pytorch_model.load_state_dict(state_dict)
File "/home/eorg/.local/lib/python2.7/site-packages/torch/nn/modules/module.py", line 334, in load_state_dict
own_state[name].copy_(param)
RuntimeError: inconsistent tensor size at /b/wheel/pytorch-src/torch/lib/TH/generic/THTensorCopy.c:51
I understood that the error is related to the shape of images. In Keras the input size is defined to be 48 by 48.
And my question is how to define in PyTorch models that of my pictures are the shape of 48x48? I couldn't find such function in the documentation and examples.
Any help would be useful!
pytorch_model.load_state_dict(state_dict)
gives you the error, then the problem is that the parameters in your saved state dict do not match the parameters inpytorch_model
. – Siphon