Unknown initializer: GlorotUniform when loading Keras model

前端 未结 10 1900
心在旅途
心在旅途 2020-11-29 04:43

I trained my CNN (VGG) through google colab and generated .h5 file. Now problem is, I can predict my output successfully through google colab but when i download that .h5 tr

10条回答
  •  心在旅途
    2020-11-29 05:12

    Wow I, just spent 6 Hours of my life trying to figure this out.. Dmitri posted a solution to this here: I trained a keras model on google colab. Now not able to load it locally on my system.

    I'm just basically reposting it here because it worked for me.

    This looks like some kind of a serialization bug in keras. If you wrap your load_model with the below CustomObjectScope thingy... all should work..

    import keras
    from keras.models import load_model
    from keras.utils import CustomObjectScope
    from keras.initializers import glorot_uniform
    
    with CustomObjectScope({'GlorotUniform': glorot_uniform()}):
            model = load_model('imdb_mlp_model.h5')
    

提交回复
热议问题