I have been running my 2013 server box since 2 weeks ago for training an AI model. I set up 30 epochs to run but since than it only ran 1 epoch as my PC config is super slow. But it generates 1 .h5 file.

My question is will this .h5 file that I trained with Xception model work for Resnet 50?


If I understand your question correctly, you are asking whether you could load the saved weights of a trained model with the Xception architecture on a a Resnet50 architecture.

Short answer: No

Long answer: Xception and Resnet50 have very different architectures.

Here is a paper comparing multilple CNNs including Xception and Resnet50: https://www.researchgate.net/publication/330478807_Deep_Feature-Based_Classifiers_for_Fruit_Fly_Identification_Diptera_Tephritidae/figures?lo=1

As you can see, the architectures are quiet different between Xception and ResNet50. Thus when you train a model, you are changing the weights and bias of the different layers of the model. If you switch models, and they are similar like let's say VGG16 and VGG19, you could import part of the weights for the layers which are similar between the two models. As far as I know, I don't know of a function which can do this operation in tensorflow or keras. But in your case, the architectures are extremely different between Xception and ResNet and there seem not to have any layers in common.

In general, one train a model, save the weights of the training, import back the weights, and use the same model for the next round of training/testing/predictions.

Hope that helps!

  • $\begingroup$ Awesome happy to hear that! I hope other people also try to answer the question so we get more insights. $\endgroup$ Sep 9 '19 at 6:55
  • $\begingroup$ exactly~! let's see whether someone could come up with different ideas :) $\endgroup$
    – Franva
    Sep 9 '19 at 6:56
  • $\begingroup$ btw, what do you call the trained .h5 file? the saved wrights fill?? do we have some shorter names? $\endgroup$
    – Franva
    Sep 9 '19 at 6:58
  • 1
    $\begingroup$ Either the saved weights file (in tensorflow): model.save_weights("yourfilename.h5") Or the saved model: model.save("yourfilename.h5"). The saved model contains all the layers, weights, biases and the optimizer features. $\endgroup$ Sep 9 '19 at 8:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.