将Tensorflow模型转换为Intel Movidius图形的问题

时间:2018-11-09 13:34:30

标签: python tensorflow machine-learning

您好,当我尝试将Intel Movidius神经棒与tensorflow结合使用时遇到了问题。我有keras模型,并将其转换为tensorflow模型。当我将其转换为Movidius图时,出现错误:

Traceback (most recent call last):
File "/usr/local/bin/mvNCCompile", line 118, in
create_graph(args.network, args.inputnode, args.outputnode, args.outfile, args.nshaves, args.inputsize, args.weights)
File "/usr/local/bin/mvNCCompile", line 104, in create_graph
net = parse_tensor(args, myriad_config)
File "/usr/local/bin/ncsdk/Controllers/TensorFlowParser.py", line 290, in parse_tensor
if have_first_input(strip_tensor_id(node.outputs[0].name)):
IndexError: list index out of range

这是我的代码:

from keras.models import model_from_json
from keras.models import load_model
from keras import backend as K
import tensorflow as tf
import nn
import os

weights_file = "weights.h5"

sess = K.get_session()
K.set_learning_phase(0)
model = nn.alexnet_model() # get keras model
model.load_weights(weights_file)

saver = tf.train.Saver()
saver.save(sess, "./TF_Model/tf_model") # convert keras to tensorflow model

tf_model_path = "./TF_Model/tf_model"

fw = tf.summary.FileWriter('logs', sess.graph)
fw.close()

os.system('mvNCCompile TF_Model/tf_model.meta -in=conv2d_1_input -on=activation_7/Softmax') # get Movidius graph

Python版本:2.7 操作系统:Ubuntu 16.04 Tensorflow版本:1.12

1 个答案:

答案 0 :(得分:0)

据我所知,ncsdk编译器无法解析正常tensorflow网络的每个部分,因此您必须修改网络并以NCS友好的方式重新保存它才能成功制作Movidius图。

有关如何修改张量流网络的更多信息,请查看the official guidance

希望它会对您有所帮助。