我仍在学习 tensorflow 和 keras,我怀疑这个问题有一个非常简单的答案,我只是因为不熟悉而错过了。
我有一个PrefetchDataset对象:
> print(tf_test)
$ <PrefetchDataset shapes: ((None, 99), (None,)), types: (tf.float32, tf.int64)>
Run Code Online (Sandbox Code Playgroud)
...由特征和目标组成。我可以使用for循环遍历它:
> for example in tf_test:
> print(example[0].numpy())
> print(example[1].numpy())
> exit()
$ [[-0.31 -0.94 -1.12 ... 0.18 -0.27]
[-0.22 -0.54 -0.14 ... 0.33 -0.55]
[-0.60 -0.02 -1.41 ... 0.21 -0.63]
...
[-0.03 -0.91 -0.12 ... 0.77 -0.23]
[-0.76 -1.48 -0.15 ... 0.38 -0.35]
[-0.55 -0.08 -0.69 ... 0.44 -0.36]]
[0 0 1 0 1 0 0 0 1 0 …Run Code Online (Sandbox Code Playgroud)