【发布时间】:2018-07-13 13:22:02
【问题描述】:
我想使用经过训练的 RNN 语言模型进行推理。所以:
我使用 c++ 加载了经过训练的模型图
tensorflow::MetaGraphDef graph_def;
TF_CHECK_OK(ReadBinaryProto(Env::Default(), path_to_graph, &graph_def));
TF_CHECK_OK(session->Create(graph_def.graph_def()));
通过以下方式加载模型参数:
Tensor checkpointPathTensor(tensorflow::DT_STRING, tensorflow::TensorShape());
checkpointPathTensor.scalar<std::string>()() = path_to_ckpt;
TF_CHECK_OK(session_->Run({{graph_def.saver_def().filename_tensor_name(), checkpointPathTensor} },{},{graph_def.saver_def().restore_op_name()},nullptr));
到目前为止,一切正常。
然后我想计算节点“output/output_batch_major”的值:
TF_CHECK_OK(session->Run(inputs,{"output/output_batch_major"},{"post_control_dependencies"}, &outputs));
我得到了错误:
2018-07-13 14:13:36.793495: F tf_lm_model_loader.cc:190] Non-OK-status: session->Run(inputs,{"output/output_batch_major"},{"post_control_dependencies"}, &outputs) status: Invalid argument: transpose expects a vector of size 1. But input(1) is a vector of size 2
[[Node: extern_data/placeholders/delayed/sequence_mask_time_major/transpose = Transpose[T=DT_BOOL, Tperm=DT_INT32, _device="/job:localhost/replica:0/task:0/device:CPU:0"](extern_data/placeholders/delayed/SequenceMask/Less, extern_data/placeholders/delayed/sequence_mask_time_major/transpose/perm)]]
Aborted (core dumped)
我使用张量板检查了图形,extern_data/placeholders/delayed/sequence_mask_time_major/transpose/perm 是大小为 2 的 Tensor,这个张量是错误中的 input(1) 吗?我该如何解决这个问题?
知道吗?提前致谢!
【问题讨论】:
标签: c++ tensorflow speech-recognition