In keras I have used to_categorical to convert by binary nx1 vector y to a nx2 matrix where the first columns is 1 if y=1 and the second column is y=0. How do I reverse this action using numpy?
Sign up to request clarification or add additional context in comments.
Comments
13
Adding to MazeRunner09's answer. If you used to_categorical from keras, you will have a list and can use a list comprehension over the entire one-hot encoded list:
y_classes = [np.argmax(y, axis=None, out=None) for y in y_test]
argmax