- TensorFlow 2.0 Quick Start Guide
- Tony Holdroyd
- 58字
- 2021-06-24 16:02:03
Casting a tensor to a NumPy/Python variable
Should you need to, you can cast a tensor to a numpy variable as follows:
print(t2.numpy())
The output will be as follows:
[[[ 0. 1. 2.] [ 3. 4. 5.]] [[ 6. 7. 8.] [ 9. 10. 11.]]]
Take this, also:
print(t2[1, 0, 2].numpy())
The output will be as follows:
8.0