Im working on a clasification model for dog breeds and Im trying to display examples of labels and their respective one hot encoded label but im getting an error saying that AxisError: axis 1 is out of bounds for array of dimension 1.
Here is my current code:
def decode_one_hot(one_hot_encoded, labels):
# Use numpy's argmax to get the index of the '1' in each encoded list
indices = np.argmax(one_hot_encoded, axis=1)
# Convert indices back to original labels
decoded_labels = [labels[index] for index in indices]
return decoded_labels
print('Example of label and one_hot_encoded label')
train_labels = decode_one_hot(y_train, breeds)
show_images(image_array= X_train, labels=train_labels, encoded_labels=y_train)
This is what i expected to achieve: Expected Result
My guess is that your array is one-dimensional, in that case the syntax would be: