Problem after converting keras model into Tensorflow pb - 将keras模型转换为Tensorflow pb后的问题

时间:2022-11-05 10:08:50

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后的问题的更多相关文章

  1. 【6】TensorFlow光速入门-python模型转换为tfjs模型并使用

    本文地址:https://www.cnblogs.com/tujia/p/13862365.html 系列文章: [0]TensorFlow光速入门-序 [1]TensorFlow光速入门-tenso ...

  2. 将keras的h5模型转换为tensorflow的pb模型

    h5_to_pb.py from keras.models import load_model import tensorflow as tf import os import os.path as ...

  3. 【4】TensorFlow光速入门-保存模型及加载模型并使用

    本文地址:https://www.cnblogs.com/tujia/p/13862360.html 系列文章: [0]TensorFlow光速入门-序 [1]TensorFlow光速入门-tenso ...

  4. Deploying Keras model on Tensorflow Serving--

    keras训练了个二分类的模型.需求是把keras模型跑到 tensorflow serving上 (TensorFlow Serving 系统用于在生产环境中运行模型) keras模型转 tenso ...

  5. [Tensorflow] 使用 model.save_weights() 保存 / 加载 Keras Subclassed Model

    在 parameters.py 中,定义了各类参数. # training data directory TRAINING_DATA_DIR = './data/' # checkpoint dire ...

  6. tensorflow 2.0 技巧 | 自定义tf.keras.Model的坑

    自定义tf.keras.Model需要注意的点 model.save() subclass Model 是不能直接save的,save成.h5,但是能够save_weights,或者save_form ...

  7. tensorflow模型ckpt转pb以及其遇到的问题

    使用tensorflow训练模型,ckpt作为tensorflow训练生成的模型,可以在tensorflow内部使用.但是如果想要永久保存,最好将其导出成pb的形式. tensorflow已经准备好c ...

  8. tflearn 中文汉字识别,训练后模型存为pb给TensorFlow使用——模型层次太深,或者太复杂训练时候都不会收敛

    tflearn 中文汉字识别,训练后模型存为pb给TensorFlow使用. 数据目录在data,data下放了汉字识别图片: data$ ls0  1  10  11  12  13  14  15 ...

  9. 将tflearn的模型保存为pb,给TensorFlow使用

    参考:https://github.com/tflearn/tflearn/issues/964 解决方法: """ Tensorflow graph freezer C ...

随机推荐

  1. ArcGIS10.2.2 Desktop直接连接数据库的具体步骤

    ArcGIS10.2.2 Desktop直接连接数据库的具体步骤,以sqlserver2008R2和oracle11G数据库为例子,这里数据库的具体安装步骤不说了,不在讨论的范畴之内. 假如数据库软件 ...

  2. NPOI对Excel的操作(Sheet转DataTable、List<T>)

    通过NPOI对Excel进行操作,这里主要是读取的操作.封装到ExcelHelper操作类中. 1 using System.Collections.Generic; 2 using NPOI.HSS ...

  3. Unable to save settings: Failed to save settings. Please restart IntelliJ IDEA 解决方案

    ubuntu 上 今天安idea 社区版,报这个错, 解决办法. 1 首先删除掉配置目录,例如安装的是idea最新的15.1版本,就删除 .ideaIC这个文件夹,重启解决了 2 而后,不大一会.又开 ...

  4. ROW_NUMBER分页的注意事项

    之前在使用ROW_NUMBER分页获取数据的时候,直接用ROW_NUMBER里的SELECT语句查出了所有的数据. like this: select * from ( select row_numb ...

  5. 可以部署在广域网执行QQ高仿版 GG2014 (源代码)

      距上次GG V3.7版本号(可在广域网部署执行的QQ高仿版 -- GG叽叽V3.7.优化视频聊天.控制很多其它相关细节)的公布.已经有50天了,这50天对于GG来说.是一个重大的飞跃. 由于这段时 ...

  6. mui框架移动开发初体验

      前  言 博主最近在接触移动APP,学习了几个小技巧,和大家分享一下. 1. 状态栏设置 现在打开绝大多数APP,状态栏都是与APP一体,不仅美观,而且与整体协调.博主是个中度强迫症患者,顶部那个 ...

  7. ConfigUtil读取配置文件工具类

    ConfigUtil package com.sso.util; import java.io.FileNotFoundException; import java.io.IOException; i ...

  8. LY.JAVA面向对象编程.封装、this、构造方法

    2018-07-07 this关键字 构造方法 /* 我们一直在使用构造方法,但是,我们确没有定义构造方法,用的是哪里来的呢? 构造方法的注意事项: A:如果我们没有给出构造方法,系统将自动提供一个无 ...

  9. vim常忘命令

    1.复制指定行到当前光标的下一行. #假设当前光标在10行,想把第5行复制到第11行 :5copy. #copy命令有2种简写'co'和't',所以也可以写成下面的格式 :5co. :5t. 参考:h ...

  10. BZOJ4566: [Haoi2016]找相同字符(后缀自动机)

    题意 题目链接 Sol 直接在SAM上乱搞 枚举前缀,用SAM统计可以匹配的后缀,具体在匹配的时候维护和当前节点能匹配的最大值 然后再把parent树上的点的贡献也统计上,这部分可以爆跳parent树 ...