I have a numpy array data set with shape (100,10). Each row is a one-hot encoding. I want to transfer it into a nd-array with shape (100,) such that I transferred each vecto
You can use numpy.argmax or tf.argmax. Example:
import numpy as np a = np.array([[0,1,0,0],[1,0,0,0],[0,0,0,1]]) print('np.argmax(a, axis=1): {0}'.format(np.argmax(a, axis=1)))
output:
np.argmax(a, axis=1): [1 0 3]
You may also want to look at sklearn.preprocessing.LabelBinarizer.inverse_transform.