Y data missing on Introduction to TensorFlow

Hi all,
The Y data (train and test) is missing in the files train_signs.h5 and test_signs.h5.
I have printed the shapes right after reading the files.
Any ideas?

See printed output
Train Keys <KeysViewHDF5 [‘list_classes’, ‘train_set_x’, ‘train_set_y’]>
Test Keys <KeysViewHDF5 [‘list_classes’, ‘test_set_x’, ‘test_set_y’]>
x_train TensorSpec(shape=(64, 64, 3), dtype=tf.uint8, name=None)
y_Train TensorSpec(shape=(), dtype=tf.int64, name=None)
x_test TensorSpec(shape=(64, 64, 3), dtype=tf.uint8, name=None)
y_test TensorSpec(shape=(), dtype=tf.int64, name=None)

Hi @Eli_Tom ,
I am not sure if we are on the same page, but if you go to item 2, it shows how to extract both y_train and y_test using tensorflow datasets.
Keep learning!

Hi @carlosrl,
Thank you for your answer.
I am extracting the Y test and train the same way I do with the X test and train.
Actually, this part of the code is provided in the exercise.
Can you send me an updated version of the files?

cell[3]
train_dataset = h5py.File(‘datasets/train_signs.h5’, “r”)
test_dataset = h5py.File(‘datasets/test_signs.h5’, “r”)

cell[4]
x_train = tf.data.Dataset.from_tensor_slices(train_dataset[‘train_set_x’])
y_train = tf.data.Dataset.from_tensor_slices(train_dataset[‘train_set_y’])

x_test = tf.data.Dataset.from_tensor_slices(test_dataset[‘test_set_x’])
y_test = tf.data.Dataset.from_tensor_slices(test_dataset[‘test_set_y’])

cell[5]
print("Train Keys " + str(train_dataset.keys()))
print("Test Keys " + str(test_dataset.keys()))
print("x_train " + str(x_train.element_spec))
print("y_Train " + str(y_train.element_spec))
print("x_test " + str(x_test.element_spec))
print("y_test " + str(y_test.element_spec))
type(x_train)

Result
Train Keys <KeysViewHDF5 [‘list_classes’, ‘train_set_x’, ‘train_set_y’]>
Test Keys <KeysViewHDF5 [‘list_classes’, ‘test_set_x’, ‘test_set_y’]>
x_train TensorSpec(shape=(64, 64, 3), dtype=tf.uint8, name=None)
y_Train TensorSpec(shape=(), dtype=tf.int64, name=None)
x_test TensorSpec(shape=(64, 64, 3), dtype=tf.uint8, name=None)
y_test TensorSpec(shape=(), dtype=tf.int64, name=None)

Why do you think that is wrong? It’s just telling you that each Y value is a scalar. It’s the label corresponding the image, right? Each image is a (64, 64, 3) Tensor, but the labels are just scalars. Or you can call them “rank 0” tensors, if you want to go full “tensor speak”. :vulcan_salute:

If you look at the next few cells, you’ll see one that enumerates the Y values and collects all the unique values. They are the numbers 0 to 5 and they then show you examples of the images and corresponding labels.

1 Like

OK,
Thank you.

Apparently, I needed to read tf.reshape spec deeper.

Thank you again,
Issue resolved.
Eli