Blu*_*482 2 tensorflow tensorflow-estimator tensorflow2.0
我已经在 tensorflow v2.0 和 v1.12.0(带有tf.enable_eager_execution())上尝试过这个。显然,如果我numpy()在我的main()函数中使用下面显示的代码片段进行调用,它就可以完美运行。但是,如果我在我的 estimator 模型函数 ie 中使用它,model_fn(features, labels, mode, params)那么它会抱怨'Tensor' object has no attribute 'numpy'.
ndarray = np.ones([3, 3])
tensor = tf.multiply(ndarray, 42)
print(tensor)
print(tensor.numpy())
Run Code Online (Sandbox Code Playgroud)
有没有其他人遇到过类似的问题?对于 tf.estimator 来说似乎是个大问题,不是吗?
它不会工作。Estimator API 与图构建相关,它不完全支持 Eager Execution。根据官方文档。
启用 Eager Execution 时,Estimator 的调用方法将起作用。但是,model_fn 和 input_fn 并没有急切地执行
https://www.tensorflow.org/api_docs/python/tf/estimator/Estimator
TF 2.0 甚至不支持自定义估算器,只支持预制估算器。
| 归档时间: |
|
| 查看次数: |
4170 次 |
| 最近记录: |