convert numpy array to 0 or 1

前端 未结 6 1570
小鲜肉
小鲜肉 2020-12-29 06:12
A = np.array([[0.94366988, 0.86095311, 0.88896715, 0.93630641, 0.74075403, 0.52849619
                  , 0.03094677, 0.85707681, 0.88457925, 0.67279696, 0.26601085,         


        
6条回答
  •  无人及你
    2020-12-29 06:54

    You can make the built-in round function element wise use np.vectorize.

    import numpy as np
    
    element_wise_round = np.vectorize(round, otypes=[np.int])
    
    print element_wise_round(A)
    

提交回复
热议问题