Numpy 实现 One-hot

x=(np.arange(np.max(x)+1)==x[:,None]).astype(np.integer)

 

参考文献:

https://blog.csdn.net/fu_shuwu/article/details/78964462

posted @ 2019-10-09 14:08  jhc888007  阅读(1163)  评论(0)    收藏  举报