C3W4 Fairness indicator lab

Int/float type error when running code.

# Use the helper function to serialize the test dataset

celeb_ds_to_tfrecord(celeb_a_test_data, TFRECORD_FILE)

error message:
TypeError                                 Traceback (most recent call last)
<ipython-input-26-4cb15f34ebb6> in <module>
      1 # Use the helper function to serialize the test dataset
----> 2 celeb_ds_to_tfrecord(celeb_a_test_data, TFRECORD_FILE)

<ipython-input-25-0a64b4fd225b> in celeb_ds_to_tfrecord(dataset, tfrecord_file)
     24     # Assign features' numpy arrays to the Example feature values
     25     output.features.feature[IMAGE_KEY].float_list.value.extend(image.numpy().tolist())
---> 26     output.features.feature[LABEL_KEY].float_list.value.append(label.numpy())
     27     output.features.feature[GROUP_KEY].bytes_list.value.append(b"Young" if group.numpy() else b'Not Young')
     28 

TypeError: array([1.], dtype=float32) has type numpy.ndarray, but expected one of: int, float`Preformatted text`

Please try with:

output.features.feature[LABEL_KEY].float_list.value.append(label.numpy()[0])
2 Likes

Worked for me, there’s an error in the lab that needs fixed

Filed a ticket to notify deeplearning.ai staff. Thank you.

Thank you! This has now been fixed! Kindly reopen the notebook from your classroom.