您的位置:首页 > 移动开发 > Objective-C

jupyter notebook + tf2.0 报错记录: AttributeError: ‘Tensor‘ object has no attribute ‘numpy‘

2020-08-22 00:28 5125 查看

jupyter notebook + tf2.0 报错记录: AttributeError: 'Tensor' object has no attribute 'numpy'

问题描述

尝试显示tf中Tensor的值,采用 tesor_instance.nupmy() 实现,运行时报错

AttributeError: in converted code:

<ipython-input-10-68deec28a095>:27 compute_loss  *
print(label.numpy())

AttributeError: 'Tensor' object has no attribute 'numpy'

解决方法

参考解决tf2 : AttributeError: ‘Tensor’ object has no attribute ‘numpy’

将涉及到 .numpy() 方法的所有函数顶层的

# @tf.function

注释掉

程序运行成功。

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐