未知的初始化程序:加载 Keras 模型时的 GlorotUniform [英] Unknown initializer: GlorotUniform when loading Keras model

查看:30
本文介绍了未知的初始化程序:加载 Keras 模型时的 GlorotUniform的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过 google colab 训练了我的 CNN (VGG) 并生成了 .h5 文件.现在的问题是,我可以通过 google colab 成功预测我的输出,但是当我下载 .h5 训练模型文件并尝试在我的笔记本电脑上预测输出时,我在加载模型时出错.

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 trained model file and try to predict output on my laptop, I am getting error when loading the model.

代码如下:

import tensorflow as tf
from tensorflow import keras
import h5py

# Initialization

loaded_model = keras.models.load_model('./train_personCount_model.h5')

和错误:

ValueError: Unknown initializer: GlorotUniform

推荐答案

我遇到了同样的问题.更改后:

I ran into the same issue. After changing:

从tensorflow导入keras

到:

导入keras

生命再次值得一过.

这篇关于未知的初始化程序:加载 Keras 模型时的 GlorotUniform的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆