吴裕雄 python 神经网络——TensorFlow pb文件保存方法
import tensorflow as tf
from tensorflow.python.framework import graph_util v1 = tf.Variable(tf.constant(1.0, shape=[1]), name = "v1")
v2 = tf.Variable(tf.constant(2.0, shape=[1]), name = "v2")
result = v1 + v2 init_op = tf.global_variables_initializer()
with tf.Session() as sess:
sess.run(init_op)
graph_def = tf.get_default_graph().as_graph_def()
output_graph_def = graph_util.convert_variables_to_constants(sess, graph_def, ['add'])
with tf.gfile.GFile("E:\\Saved_model\\combined_model.pb", "wb") as f:
f.write(output_graph_def.SerializeToString())

from tensorflow.python.platform import gfile with tf.Session() as sess:
model_filename = "E:\\Saved_model\\combined_model.pb" with gfile.FastGFile(model_filename, 'rb') as f:
graph_def = tf.GraphDef()
graph_def.ParseFromString(f.read())
result = tf.import_graph_def(graph_def, return_elements=["add:0"])
print(sess.run(result))

吴裕雄 python 神经网络——TensorFlow pb文件保存方法的更多相关文章
- 吴裕雄 python 神经网络——TensorFlow ckpt文件保存方法
import tensorflow as tf v1 = tf.Variable(tf.random_normal([1], stddev=1, seed=1)) v2 = tf.Variable(t ...
- 吴裕雄 python 神经网络——TensorFlow 数据集基本使用方法
import tempfile import tensorflow as tf input_data = [1, 2, 3, 5, 8] dataset = tf.data.Dataset.from_ ...
- 吴裕雄 python 神经网络——TensorFlow 滑动平均类的保存
import tensorflow as tf v = tf.Variable(0, dtype=tf.float32, name="v") for variables in tf ...
- 吴裕雄 python 神经网络TensorFlow实现LeNet模型处理手写数字识别MNIST数据集
import tensorflow as tf tf.reset_default_graph() # 配置神经网络的参数 INPUT_NODE = 784 OUTPUT_NODE = 10 IMAGE ...
- 吴裕雄 python 神经网络——TensorFlow 花瓣分类与迁移学习(4)
# -*- coding: utf-8 -*- import glob import os.path import numpy as np import tensorflow as tf from t ...
- 吴裕雄 python 神经网络——TensorFlow 花瓣分类与迁移学习(3)
import glob import os.path import numpy as np import tensorflow as tf from tensorflow.python.platfor ...
- 吴裕雄 python 神经网络——TensorFlow 花瓣分类与迁移学习(2)
import glob import os.path import numpy as np import tensorflow as tf from tensorflow.python.platfor ...
- 吴裕雄 python 神经网络——TensorFlow 花瓣分类与迁移学习(1)
import glob import os.path import numpy as np import tensorflow as tf from tensorflow.python.platfor ...
- 吴裕雄 python 神经网络——TensorFlow 花瓣识别2
import glob import os.path import numpy as np import tensorflow as tf from tensorflow.python.platfor ...
随机推荐
- 517,sytlus/sass/less的区别
均具有“变量”,“混合”,“嵌套”,“继承”,“颜色混合”五大基本特性 scss和less语法较为严禁,less要求一定要使用大括号“{}”,scss和stylus可以通过缩进表示层次与嵌套关系 sc ...
- 转载:Bass management
https://kenrockwell.com/audio/bass-management.htm https://www.axiomaudio.com/blog/bassmanagement htt ...
- 【Python】数值运算函数
- C#中通过SendARP读取MAC地址
C#中通过SendARP读取MAC地址: using System.Runtime.InteropServices; publicstaticstring GetMacBySendARP(string ...
- truffle编译合约常见问题及其在私链上的部署与交互
一.初始化truffle项目 truffle init //初始化truffle项目文件夹 将写好的合约文件放到contract文件夹中 truffle compile //编译合约 (注意!! ...
- 关于进程,I/O模型的文章
PHP类 http://rango.swoole.com/archives/508 Node https://github.com/DoubleSpout/threadAndPackage
- CentOS7服务器状态下安装xampp
遇到的问题 1.远程不能访问phpmyadmin,只能在本地访问,但是本地为命令行模式. 需要修改一下服务器端的配置,我们找到 /opt/lampp/etc/extra/httpd-xampp.con ...
- PHP中使用CURL实现Get和Post请求方法
1.cURL介绍 cURL 是一个利用URL语法规定来传输文件和数据的工具,支持很多协议,如HTTP.FTP.TELNET等.最爽的是,PHP也支持 cURL 库.本文将介绍 cURL的一些高级特性, ...
- ACM的探索之Keen On Evrything But Triangle(我觉得可以很接近啦!!)
#include<bits/stdc++.h> using namespace std; int main() { int n,q,l,r; while(cin>>n>& ...
- blog主题——马路
blog主题,存储一下 css /************************************************** 第一部分:所有的模板都使用的公共样式.公告样式是为了更好的向前 ...