首页 > 解决方案 > NotImplementedError:TPU 不支持类型为 AssignVariableOp (AssignVariableOp) 的操作进行推理

问题描述

我正在尝试导出 TPUEstimator 类型的分类器的 SavedModel。由于我试图导出模型以在 GPU/CPU 上运行预测,因此 TPUEstimator 的 use_tpu 参数设置为 False。

当我尝试保存模型时,抛出以下错误:

NotImplementedError: Operation of type AssignVariableOp
(AssignVariableOp) is not supported on the TPU for inference. Execution 
will fail if this op is used in the graph. Make sure your variables are 
using variable_scope.

由于我计划通过 GPU/CPU 为模型提供服务,因此 Op 应该不是问题。如何将此估算器导出为 SavedModel?

标签: tensorflow

解决方案


这可能会有所帮助,就在调用 export_savedmodel(...) 之前

estimator._export_to_tpu = False


推荐阅读