Problem after converting keras model into Tensorflow pb - 将keras模型转换为Tensorflow pb后的问题
I'm using keras 2.1.* with tensorflow 1.13.* backend. I save my model during training with .h5 format and after that I convert it into protobuf (.pb) model. Everything looks good during converting process, but the result of tensorflow model is a bit weird. It shows a little bit different results. Also I'm loading keras model with not compiled mode. Something like this.
import keras
keras.models.load_model('model.h5', compile=False)
Solution 1
Most probable the problem is related to running environment. There are some variables which are being computed in training phase for future use. If you don't change to test phase, it will use current values. For example dropout and batch normalization. If you use it in training mode, then for mean and variance it will use current values, but in test time it will use moving_mean and moving_variance. That's why you should call
import keras.backend as K
k.set_learning_phase(0) # 0 testing, 1 training mode
aipool discussion: https://ai-pool.com/d/problem_after_converting_keras_model_into_tensorflow_pb
Problem after converting keras model into Tensorflow pb - 将keras模型转换为Tensorflow pb后的问题的更多相关文章
- 【6】TensorFlow光速入门-python模型转换为tfjs模型并使用
本文地址:https://www.cnblogs.com/tujia/p/13862365.html 系列文章: [0]TensorFlow光速入门-序 [1]TensorFlow光速入门-tenso ...
- 将keras的h5模型转换为tensorflow的pb模型
h5_to_pb.py from keras.models import load_model import tensorflow as tf import os import os.path as ...
- 【4】TensorFlow光速入门-保存模型及加载模型并使用
本文地址:https://www.cnblogs.com/tujia/p/13862360.html 系列文章: [0]TensorFlow光速入门-序 [1]TensorFlow光速入门-tenso ...
- Deploying Keras model on Tensorflow Serving--
keras训练了个二分类的模型.需求是把keras模型跑到 tensorflow serving上 (TensorFlow Serving 系统用于在生产环境中运行模型) keras模型转 tenso ...
- [Tensorflow] 使用 model.save_weights() 保存 / 加载 Keras Subclassed Model
在 parameters.py 中,定义了各类参数. # training data directory TRAINING_DATA_DIR = './data/' # checkpoint dire ...
- tensorflow 2.0 技巧 | 自定义tf.keras.Model的坑
自定义tf.keras.Model需要注意的点 model.save() subclass Model 是不能直接save的,save成.h5,但是能够save_weights,或者save_form ...
- tensorflow模型ckpt转pb以及其遇到的问题
使用tensorflow训练模型,ckpt作为tensorflow训练生成的模型,可以在tensorflow内部使用.但是如果想要永久保存,最好将其导出成pb的形式. tensorflow已经准备好c ...
- tflearn 中文汉字识别,训练后模型存为pb给TensorFlow使用——模型层次太深,或者太复杂训练时候都不会收敛
tflearn 中文汉字识别,训练后模型存为pb给TensorFlow使用. 数据目录在data,data下放了汉字识别图片: data$ ls0 1 10 11 12 13 14 15 ...
- 将tflearn的模型保存为pb,给TensorFlow使用
参考:https://github.com/tflearn/tflearn/issues/964 解决方法: """ Tensorflow graph freezer C ...
随机推荐
- JDK源码分析(12)之 ConcurrentHashMap 详解
本文将主要讲述 JDK1.8 版本 的 ConcurrentHashMap,其内部结构和很多的哈希优化算法,都是和 JDK1.8 版本的 HashMap是一样的,所以在阅读本文之前,一定要先了解 Ha ...
- javaweb闲暇小程序之抽签程序
学自潭州学院视频 主程序页面截图 <%@ page language="java" contentType="text/html; charset=UTF-8&qu ...
- HTML与CSS的一些知识(三)
CSS: 1.三大样式:行内(内嵌).内部(内联).外部(外联):基本都知道. 2.三大特性: a.继承性:父级样式会被子级继承(!important不会被继承,<a></a> ...
- ValueObject
ValueObject When programming, I often find it's useful to represent things as a compound混合物. A 2D co ...
- Jenkins去GitLab拉取Java代码自动打包
jenkins的部署 一.部署git 1)先检查系统是否已经自带了git,如果有,就卸载 $ rpm -qa | grep git && rpm -e git --nodeps 2)开 ...
- 北京AI外包团队 祝大家2019事业有事,大吉大利!
未来已来,以人工智能为核心的科技力量,在重新塑造着我们生活的环境.这种重新塑造的现象如此之明显,力量如此强大,以至于越来越多的人在讨论,我们面临着新一轮的工业革命.而且现在我们面临的这次新的科技力量, ...
- 51nod 1201 整数划分 dp
1201 整数划分 基准时间限制:1 秒 空间限制:131072 KB 收藏 关注 将N分为若干个不同整数的和,有多少种不同的划分方式,例如:n = 6,{6} {1,5} {2,4} {1,2 ...
- Mysql 索引之B+tree
InnoDB使用的是聚簇索引,将主键组织到一棵B+树中,而行数据就储存在叶子节点上,若使用"where id = 14"这样的条件查找主键,则按照B+树的检索算法即可查找到对应的叶 ...
- EM公式推导
纯手写,字很丑,人也很丑.. E步公式是怎么来的呢?推导步骤如下, EM算法核心思想是先给定初始θ,求样本X,和隐变量z的期望(实际上是个函数),可以画一个曲线,M步:然后不断滑动θ,找到使得期望最大 ...
- Spring Boot 返回 JSON 数据,一分钟搞定!
如何返回 JSON 数据? 在 Spring Boot 中返回 JSON 数据很简单,如下几步. 加入依赖 12345678910 <parent> <groupId>org. ...