MMdnn icon indicating copy to clipboard operation
MMdnn copied to clipboard

Help convert a VGG 16 model from keras to pytorch

Open higherdefender opened this issue 5 years ago • 4 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!

higherdefender avatar Oct 13 '20 05:10 higherdefender

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

cookieli avatar Feb 03 '21 06:02 cookieli

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?

JoeBlair avatar Jun 17 '21 06:06 JoeBlair

Thanks! Yeah, I think the output will be slightly different. But is the overall prediction the same?

On Wed, Jun 16, 2021 at 11:12 PM Joe @.***> wrote:

Just to hijack this thread! I have also done this @.*** https://github.com/higherdefender if you didnt manage i can advise)

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

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/microsoft/MMdnn/issues/902#issuecomment-862957830, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACYY6L7DGHXRUCOVNBKMKMLTTGG6PANCNFSM4SOEPY3A .

-- dhruvjain.info | twitter.com/dj_hci

higherdefender avatar Jun 17 '21 08:06 higherdefender

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.

JoeBlair avatar Jun 17 '21 08:06 JoeBlair