How to load pre-trained model weight (.pth) by using keras?

I have exported a trained model’s weight by using, '/path/to/weight/entire_model.pth')
I am wondering is there any way I could load the weight by using keras and modify the pre trained model’s layers of my own?

You can use Pytorch2Keras library.

k_model = pytorch_to_keras(model, input_var, [(10, input_size, input_size,)], verbose=True, names='short')  

Thank you so much for the suggestion.
I was running through the documentation, found that the model converted by pytorch2Keras seems not include CNN. Is that so?
Is there any method to load pre trained CNN weights using keras as well?

What do you mean by CNN layer? I assume that you are pointing CONV2D or CONV. They are both supported. You can easily restore you weights using Keras.

1 Like