可以将TensorFlow迭代器引用转换为Numpy数组吗?

smdnsysy  于 2023-05-07  发布在  其他
关注(0)|答案(1)|浏览(121)
$ print(sample_tensor) 

Tensor("IteratorGetNext:0", shape=(20, 26, 26), dtype=float32)

$ print(type(sample_tensor))

<class 'tensorflow.python.framework.ops.Tensor'>

我想将sample_tensor转换为numpy数组

dwthyt8l

dwthyt8l1#

我相信简单:

sample_eager_tensor = tf.convert_to_tensor(sample_tensor)
numpy_tensor = sample_eager_tensor.numpy()

应该可以

相关问题