您当前的位置: 首页 >  numpy

星夜孤帆

暂无认证

  • 4浏览

    0关注

    626博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

使用numpy进行one_hot编码

星夜孤帆 发布时间:2018-10-19 16:15:58 ,浏览量:4

import numpy as np
def transform_one_hot(labels):
  n_labels = np.max(labels) + 1
  one_hot = np.eye(n_labels)[labels]
  return one_hot
labels = np.array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
one_hot = transform_one_hot(labels)
print(one_hot)

https://blog.csdn.net/zhongranxu/article/details/79332154

关注
打赏
1636984416
查看更多评论
立即登录/注册

微信扫码登录

0.0392s