microsoft / MMdnn

MMdnn is a set of tools to help users inter-operate among different deep learning frameworks. E.g. model conversion and visualization. Convert models between Caffe, Keras, MXNet, Tensorflow, CNTK, PyTorch Onnx and CoreML.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Help convert a VGG 16 model from keras to pytorch

higherdefender opened this issue · comments

Hello! I’m very new to machine learning and I’m trying to convert a trained VGG-16 based model (with a modified fc layer) from keras to pytorch. Can MMdnn help with this? If yes, how should I go about it? I tried for some time to create some commands myself but none worked.

If not, is there any other way I can copy weights from keras VGG to pytorch VGG? Can someone guide me as I really feel out of my depths here?

Thank you really for your help!

Yes, that's what mmdnn does. Maybe you should look at intros in our repo.

commented

Just to hijack this thread! I have also done this (@higherdefender if you didnt manage i can advise)

however, I get different outputs from the keras network and the torch network. Is this normal?

commented

No the predictions differ between the two models on the same data (with same normalisation). Not only are the probabilities different but the argmax too. I can see that the convolutional layers have the same weights, however the fully connected are different which i find strange - maybe i'm missing something.