【发布时间】:2020-02-27 16:50:48
【问题描述】:
我已经调试这个问题一段时间了。我开发了一个 LSTM 编码器解码器模型,我计划在 C++ 中部署它。
以 .pb 文件格式保存模型后,我可以导入模型和数据并将其部署在 python 中。但是,当我尝试使用 C++ API 导入图形时,函数 TF_GraphImportGraphDef() 返回错误代码 TF_NOT_FOUND。
我怀疑,这是因为我使用的是光束搜索方法,而我在 Windows 上使用 Bazel 生成的 tensorflow.dll/lib 不包含 op GatherTree 的符号。
我想知道是否有人以前遇到过这个问题或对此问题有任何解决方案。
链接到_beam_search_ops.dll 是一种可能的解决方案吗?我也尝试过使用c_api.h 中提供的TF_LoadLibrary() 函数。但是,我无法加载库。
我们将不胜感激。另外,我正在使用 tensorflow 1.14 版。
【问题讨论】:
-
您检查过
TF_Status结构中的消息吗? (您可以通过TF_Message()获得)。关于加载额外的 DLL,TF_LoadLibrary应该可以工作,为什么它不适合你? -
嗨,我刚刚找到了一个解决方案,其中出于某种原因我还必须链接“_pywrap_tensorflow_internal.pyd”库。 (来源:stackoverflow.com/questions/50115117/…)。现在可以成功加载dll。但是,当我尝试导入图形时,它仍然失败,但这次出现了不同的错误代码,即 TF_INVALID_ARGUMENT。这些错误代码表示什么?有没有关于这些的文档?
-
@NarayanNarvekar 在此处查看有关这些错误的文档:tensorflow.org/api_docs/python/tf/errors/InvalidArgumentError
This may occur, for example, if an operation is receives an input tensor that has an invalid value or shape. For example, the tf.matmul op will raise this error if it receives an input that is not a matrix, and the tf.reshape op will raise this error if the new shape does not match the number of elements in the input tensor.您会在图形导入时看到它,这感觉很奇怪——通常我希望在推理过程中会发生这种错误。 -
@HanClinto 我也遇到了这个问题,并意识到这个问题没有多大意义。这是真的。这些错误实际上与“error_codes.proto”中的错误值相同。通过 TF_Message() 方法读取错误消息后,我意识到这是加载的 dll 之间的版本不匹配问题。接下来我将发布对我有用的解决方案。
标签: tensorflow machine-learning lstm sequence-to-sequence tensorflow-c++