Exercise

Using one-hot encoding to represent images

Neural networks expect the labels of classes in a dataset to be organized in a one-hot encoded manner: each row in the array contains zeros in all columns, except the column corresponding to a unique label, which is set to 1.

The fashion dataset contains three categories:

  1. Shirts
  2. Dresses
  3. Shoes

In this exercise, you will create a one-hot encoding of a small sample of these labels.

Instructions

100 XP
  • Initialize the ohe_labels variable to hold the one-hot encoded array.
  • Use np.where() to find the location of the category of the item in each iteration in categories.
  • Assign a 1 into the correct row/column combination in every iteration.