How to convert one-hot encodings into integers?

后端 未结 7 1490
夕颜
夕颜 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:19

    While I strongly suggest to use numpy for speed, mpu.ml.one_hot2indices(one_hots) shows how to do it without numpy. Simply pip install mpu --user --upgrade.

    Then you can do

    >>> one_hot2indices([[1, 0], [1, 0], [0, 1]])
    [0, 0, 1]
    

提交回复
热议问题