尝试显示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
注释掉
程序运行成功。