I want slicing dataset in tf.data. My data is like this:
dataset = tf.data.Dataset.from_tensor_slices([[0, 1, 2, 3, 4],
[1, 2, 3, 4, 5],
[2, 3, 4, 5, 6],
[3, 4, 5, 6, 7],
[4, 5, 6, 7, 8]])
Then the main data is:
[0 1 2 3 4]
[1 2 3 4 5]
[2 3 4 5 6]
[3 4 5 6 7]
[4 5 6 7 8]
I want create other tensor dataset that contain data like this:
[[1, 2],
[2, 3],
[3, 4],
[4, 5],
[5, 6]]
In the numpy it is like this:
dataset[:,1:3]
How can do this in TensorFlow?
Update:
I do that with this:
dataset2 = dataset.map(lambda data: data[1:3])
for val in dataset2:
print(val.numpy())
But I think there is good solutions.