SDL中文论坛
标题:
汉字分类器
[打印本页]
作者:
ancientcc
时间:
2017-11-17 09:46
标题:
汉字分类器
本帖最后由 ancientcc 于 2017-11-17 10:28 编辑
花了几天复习tensorflow,终于可以用你的模型了。从百度网盘下载模型,由它们生成C++可运行的*.pb时却报错了。
(, 下载次数: 1897)
上传
点击文件名下载附件
以下是生成*.pb的代码。关于更多把训练出的模型保存成C++可运行的*.pb格式,参考
C++运行TensorFlow模型
的“
五、保存训练出的模型
”。
import tensorflow as tf;
from tensorflow.python.framework import graph_util;
saver = tf.train.import_meta_graph("/mnt/MNIST_model/chinese-rec-model-16001.meta");
with tf.Session() as sess:
saver.restore(sess, "/mnt/MNIST_model/chinese-rec-model-16001");
graph_def = tf.get_default_graph().as_graph_def();
output = graph_util.convert_variables_to_constants(sess, graph_def, ['fc2/logits']);
with tf.gfile.GFile("/mnt/MNIST_model/combined_model.pb", "wb") as f:
f.write(output.SerializeToString());
复制代码
安装的是Windows 10,是通过docker安装的tensroflow 0.12.0。从github下载chinese_character_recognition_bn.py,能够训练。不过14轮后被系统Killed,我估计是内存等原因,毕竟我的PC就是个8G的笔记本。运行用的命令是你在github的示例命令。
python chinese_character_recognition_bn.py --mode=train --max_steps=16002 --eval_steps=100 --save_steps=500
复制代码
这是训练时控制台输出情况。
(, 下载次数: 1860)
上传
点击文件名下载附件
欢迎光临 SDL中文论坛 (http://www.libsdl.cn/bbs/)
Powered by Discuz! X3.3