【发布时间】:2018-09-26 04:01:36
【问题描述】:
我是 tensorflow 的新手,所以我尝试了官方文档中出现的每一个命令。
如何正确打印结果dataset?这是我的例子:
import tensorflow as tf
import numpy as np
sess = tf.Session()
X = tf.constant([[[1, 2, 3], [3, 4, 5]], [[3, 4, 5], [5, 6, 7]]])
Y = tf.constant([[[11]], [[12]]])
dataset = tf.data.Dataset.from_tensor_slices((X, Y))
dataset
print type(dataset)
# print help(dataset)
# print dataset.output_classes
# print dataset.output_shapes
【问题讨论】:
-
print(dataset)呢? -
print(dataset)给<BatchDataset shapes: ((?, 2, 3), (?, 1, 1)), types: (tf.int32, tf.int32)> -
你会期待什么?
-
我的预期输出类似于
[[1,2,3],[3,4,5]],[11]和[[3,4,5],[5,6,7]],[12],即特征与其标签配对。 -
您可以使用
list(dataset.as_numpy_iterator())。对于测试,您也可以使用for x in dataset.take(10).as_numpy_iterator(): print(x)。
标签: tensorflow