我正在试图弄清楚如何调用Tensorflow的C ++ API。
我有以下Python代码:
with open("logfile.txt", "w") as logFile:
logFile.write("detection_boxes=" + str(detection_boxes))
logFile.write("detection_scores=" + str(detection_scores))
logFile.write("detection_classes=" + str(detection_classes))
logFile.write("num_detections=" + str(num_detections))
logFile.write("image_tensor=" + str(image_tensor))
(boxes, scores, classes, num) = sess.run(
[detection_boxes, detection_scores, detection_classes, num_detections],
feed_dict={image_tensor: image_np_expanded})
其中detection_boxes,detection_scores,detection_classes,num_detections和image_tensor是张量。当str()应用于print语句时,它们如下所示:
detection_boxes=Tensor("detection_boxes:0", dtype=float32)
detection_scores=Tensor("detection_scores:0", dtype=float32)
detection_classes=Tensor("detection_classes:0", dtype=float32)
num_detections=Tensor("num_detections:0", dtype=float32)
image_tensor=Tensor("image_tensor:0", shape=(?, ?, ?, 3), dtype=uint8)
但是,似乎Tensorflow的C ++ API的Session Run()调用具有不同的签名。在session.h中,
虚拟状态运行(const std :: vector>& inputs,const std :: vector& output_tensor_names,const std :: vector& target_node_names,std :: vector * outputs)= 0;
似乎C ++ API需要vector而不是Tensors的列表/集合。
如何使用与Python代码等效的参数调用C ++ API?
非常感谢您的帮助!