|
5#
楼主 |
发表于 2019-8-30 15:02:33
|
只看该作者
本帖最后由 jiajia1990 于 2019-8-30 15:12 编辑
我单独把下载的Inception_resnet_v1的pb模型转换时报错的Rsqrt部分摘取出来,编辑如下代码:
def create_two_graph(feed):
x = tf.placeholder(tf.float32, [None, 128], name="square_input")
print(x.name)
y = tf.square(x, name="square")
y = tf.reduce_sum(y, 1, keep_dims=True, name="sum")
y = tf.rsqrt(y, name="rsqrt")
outpout = tf.multiply(x, y)
print(outpout.name)
with tf.Session() as sess:
my_output = sess.run(outpout, feed_dict={x: feed})
graph_def = tf.get_default_graph().as_graph_def()
output_graph_def = graph_util.convert_variables_to_constants(sess, graph_def, ["Mul"])
with tf.gfile.GFile("./square.pb", "wb") as f:
f.write(output_graph_def.SerializeToString())
生成pb文件后在电脑上试的没有错误,把pb文件拷贝到板子上后,转换代码如下:
from rknn.api import RKNN
INPUT_SIZE =128
if __name__ == '__main__':
rknn = RKNN()
rknn.config(channel_mean_value='0 0 0 255')
print('--> Loading model')
rknn.load_tensorflow(tf_pb='square.pb', inputs=['square_input'], outputs=['MM
ul'], input_size_list=[[INPUT_SIZE]])
print('done')
print('--> Building model')
rknn.build(do_quantization=False)
print('done')
rknn.export_rknn('./square.rknn')
rknn.release()
转换时还是报Rsqrt相关的错误,显示如下:
--> Loading model
W Not match node rsqrt Rsqrt
E Catch exception when loading tensorflow model: square.pb!
T Traceback (most recent call last):
T File "rknn/api/rknn_base.py", line 185, in rknn.api.rknn_base.RKNNBase.load_tensorflow
T File "rknn/base/RKNNlib/converter/convert_tf.py", line 589, in rknn.base.RKNNlib.converter.convert_tf.convert_tf.match_paragraph_and_param
T File "rknn/base/RKNNlib/converter/convert_tf.py", line 488, in rknn.base.RKNNlib.converter.convert_tf.convert_tf._tf_push_ready_node
T TypeError: 'NoneType' object is not iterable
done
--> Building model
E Model or data is None, please load model first.
done
E RKNN model data is None, please load model first!
这个Rsqrt的节点,板子不能匹配吗?
|
|