How to convert one-hot encodings into integers?

后端 未结 7 1509
夕颜
夕颜 2021-01-07 16:22

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

7条回答
  •  无人及你
    2021-01-07 17:07

    Simply use np.argmax(x, axis=1)

    Example:

    import numpy as np
    array = np.array([[0, 1, 0, 0], [0, 0, 0, 1]])
    print(np.argmax(array, axis=1))
    > [1 3]
    

提交回复
热议问题