1

dataset has 400 datas, every data has 3 features, every feature is a list,for example:

data1=[[1,2],[4,5],[7,8]]

so the shape of dataset is (400,3,2)

I want to import these dataset to train model with eager mode like(https://www.tensorflow.org/guide/eager).

according to(How to input a list of lists with different sizes in tf.data.Dataset) I tried following way:

dataset=tf.data.Dataset.from_generator(lambda: dataset, tf.int32, output_shapes=[None])
iterator=tf.contrib.eager.Iterator(dataset)
for x in iterator:
    print (x)

it didn't work

then, I tried tf.data.Dataset.from_tensor_slices and got the same result.

I fond one interest thing which is that tf.data.Dataset.from_generator and tf.data.Dataset.from_tensor_slices only consume 2D tensors , because I fond the following way is ok:

dataset=tf.data.Dataset.from_generator(lambda: data1, tf.int32, output_shapes=[None])

how to import dataset with more than one features?

andy
  • 1,951
  • 5
  • 16
  • 30

0 Answers0