I followed the steps mentioned in the repo to convert pytorch model to a keras model. the converted model actually have the same architecture but when I use predict from it I find different result. with some debugging I found that the weights of the converted model is different from the original.
what I did:
# load the model
model = torch.load('torch_model.pth')
# make dummy inputs
input_np1 = np.random.uniform(0, 1, (1, 3, 224, 224))
input_var1 = Variable(torch.FloatTensor(input_np1)).cuda()
input_np2 = np.random.uniform(0, 1, (1, 3, 224, 224))
input_var2 = Variable(torch.FloatTensor(input_np2)).cuda()
from pytorch2keras.converter import pytorch_to_keras
# convert to keras model (takes two inputs)
k_model = pytorch_to_keras(model, [input_var1, input_var2], [(3, 224, 224), (3, 224, 224)], verbose=True)
# save keras model
k_model.save('keras_model.h5', include_optimizer=True)
I got the weights of the first layer from the original and the converted model to see the difference. the difference between them was:
I followed the steps mentioned in the repo to convert pytorch model to a keras model. the converted model actually have the same architecture but when I use predict from it I find different result. with some debugging I found that the weights of the converted model is different from the original.
what I did:
I got the weights of the first layer from the original and the converted model to see the difference. the difference between them was:
how can I make sure that both models have the same weights and generate the same output?