x=tf.constant([2.1301,3.0102,3.3203])
x=x.numpy
for i in range(3):
print(round(x[i],2))
运行报错:
TypeError Traceback (most recent call last)
in
2 x=x.numpy
3 for i in range(3):
----> 4 print(round(x[i],2))
TypeError: ‘method’ object is not subscriptable
解决办法:
x=x.numpy后少了括号,补上x=x.numpy()