I am trying to find the number of classes in Cifar-10 dataset, but it gives me the error below:

TypeError: unhashable type: 'numpy.ndarray'

cifar10 = tf.keras.datasets.cifar1
(x_train, y_train), (x_test, y_test) = cifar10.load_data()
print(x_train.shape, y_train.shape, x_test.shape, y_test.shape)
# number of classes
import numpy as np
from numpy import array

K = len(set(y_train))
# calculate total number of classes

print("number of classes:", K)
  • $\begingroup$ Try converting the numpy array to a list using the tolist method before converting it to a set. $\endgroup$
    – Oxbowerce
    Apr 19 at 7:43

1 Answer 1

#number of classes

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.