Keras save model issue

半城伤御伤魂 提交于 2019-12-03 21:51:48

For variational loss you are using many variable not known by Keras module. You need to pass them through custom_objects param of load_model function.

In your case:

vae.save('./vae_'+str(cluster_num)+'.h5')
vae.summary()

del vae

from keras.models import load_model
vae = load_model('./vae_'+str(cluster_num)+'.h5', custom_objects={'latent_dim': latent_dim, 'epsilon_std': epsilon_std, 'vae_loss': vae_loss})
vae.summary()

If you load model (.h5) file in your new py file, you can use load_model('/.h5', compile = False). Because you do not need to any custom objects (i.e loss function or latent_dim, etc) in prediction step.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!