tf tensor 转numpy array
时间: 2023-12-01 12:03:09 浏览: 157
variable, tensor与numpy区别
使用tf.Session()可以将TensorFlow的Tensor对象转换为NumPy的数组。例如,可以使用以下代码将Tensor对象`mm`转换为NumPy数组:
```python
import tensorflow as tf
import numpy as np
mm = tf.convert_to_tensor([1, 3, 6, 2])
with tf.Session() as sess:
mm_array = sess.run(mm)
print(mm_array)
```
阅读全文