TypeError: Unexpected keyword argument passed to optimizer: learning_rate

前端 未结 13 1592
故里飘歌
故里飘歌 2021-02-13 04:14

I am trying to load a Keras model which was trained on an Azure VM (NC promo). But I am getting the following error.

TypeError: Unexpected keyword argumen

13条回答
  •  梦如初夏
    2021-02-13 05:00

    Did you use a custom optimizer?

    If so, you can load like this:

    model = load_model('my_model_name.h5', custom_objects={
        'Adam': lambda **kwargs: hvd.DistributedOptimizer(keras.optimizers.Adam(**kwargs))
    })
    

    Alternatively you can load your model with model = load_model('my_model_name.h5', compile=False) and then add an optimizer and recompile, but that will lose your saved weights.

提交回复
热议问题