Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 以稠密层为最后一层冻结张量流_Python_Opencv_Tensorflow - Fatal编程技术网

Python 以稠密层为最后一层冻结张量流

Python 以稠密层为最后一层冻结张量流,python,opencv,tensorflow,Python,Opencv,Tensorflow,操作系统:ubuntu 16.04.1 TensorFlow版本:1.3.0 尝试冻结TensorFlow模型(以便可以由opencv dnn加载),但它总是返回错误消息 AssertionError:回归_输出不在图中 最低代码: from __future__ import absolute_import from __future__ import division from __future__ import print_function import numpy as np impo

操作系统:ubuntu 16.04.1 TensorFlow版本:1.3.0

尝试冻结TensorFlow模型(以便可以由opencv dnn加载),但它总是返回错误消息

AssertionError:回归_输出不在图中

最低代码:

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import numpy as np
import tensorflow as tf

features = {'x' : tf.placeholder(tf.float32, [None, 128, 128, 2], name = 'input')}        
model = tf.reshape(features['x'], [-1, 128*128*2])
model = tf.layers.dense(inputs = model, units = 8, name = 'regression_output')

with tf.Session() as sess:
    sess.run(tf.global_variables_initializer())

    saver = tf.train.Saver()
    saver.save(sess, 'reshape.ckpt')
    tf.train.write_graph(sess.graph.as_graph_def(), "", 'graph.pb')
命令:

python3 ~/.keras2/lib/python3.5/site-packages/tensorflow/python/tools/freeze_graph.py --input_graph=graph.pb --input_checkpoint=reshape.ckpt --output_graph=frozen_graph.pb --output_node_names=regression_output
--output_node_names=回归_output
,但保存的模型中没有回归_output

输出的名称是
回归\输出/BiasAdd
。所以这个命令

python /usr/local/lib/python2.7/dist-packages/tensorflow/python/tools/freeze_graph.py --input_graph=graph.pb --input_checkpoint=reshape.ckpt --output_graph=frozen_graph.pb --output_node_names=regression_output/BiasAdd

可以深度学习lib库,但它又工作了,这又是一个奇怪的TySoFrand设计,我希望有一天,它可以有另一个功能丰富、易于部署和易于使用的深度学习库,并取代像TensorFlow这样的复杂的框架。