pytorch实现onehot编码转为普通label标签
2020-02-13 11:51
876 查看
label转onehot的很多,但是onehot转label的有点难找,所以就只能自己实现以下,用的topk函数,不知道有没有更好的实现
one_hot = torch.tensor([[0,0,1],[0,1,0],[0,1,0]]) print(one_hot) label = torch.topk(one_hot, 1)[1].squeeze(1) print(label)
tensor([[0, 0, 1], [0, 1, 0], [0, 1, 0]]) tensor([2, 1, 1])
以上这篇pytorch实现onehot编码转为普通label标签就是小编分享给大家的全部内容了,希望能给大家一个参考
您可能感兴趣的文章:
相关文章推荐
- iOS利用Label实现的简单高性能标签TagView
- pytorch实现带标签格式数据的模型训练
- 利用普通的input标签实现获取后台时间再格式化,再进行修改保存
- logistic Regression+doc2vec实现多标签(multi_label)分类
- base64编码的文本 转为 图片 实现上传保存
- Java基于线程实现带有滚动效果的Label标签实例
- 二分类问题打标签label以及求loss的选择——从accuracy底层实现代码理解
- ASP实现清除HTML标签,清除 空格等编码
- 在C#中实现标签(Label)随鼠标移动而移动
- 利用sklearn的LabelEncoder对标签进行数字化编码
- 标签编码、独热编码大不同 - Python 实现
- pandas 中对特征进行硬编码和onehot编码的实现
- ActivityGroup + GridView 实现Tab分页标签(將Activity转为View)
- javascript实现label标签跳出循环操作
- 实现下拉内容从数据库中动态读取--->Struts标签:和LabelValueBean的使用
- bootstrap 表单 label 和 input 实现左标签右输入布局
- android LabelView实现标签云效果
- [pytorch] 深度学习分割网络U-net的pytorch模型实现 原创 2017年03月08日 21:48:21 标签: python / 深度学习 / 生物图
- HTML基础 body标签text属性将普通文本颜色改为白色,实现有趣的密文效果
- 点击radio的文本时,不能选中相应的radio,可用label标签实现。