栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

pytorch 参数_pytorch softmax函数?

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

pytorch 参数_pytorch softmax函数?

文章目录

一、torch.max(input, dim) 函数二、实例参考链接


一、torch.max(input, dim) 函数
output = torch.max(input, dim)

输入:
input 是一个tensor
dim 是 max 函数索引的维度,dim 为 0 时返回每列最大值,dim 为 1 时返回每行最大值

输出:
函数会返回两个tensor,第一个 tensor 是某维度(dim)上的最大值;第二个 tensor 是最大值的索引(位置)。


二、实例
import torch
a = torch.tensor([[1,5,62,54], [2,6,2,6], [2,65,2,6]])
print(a)
# dim 为 1 时返回每行最大值
print(torch.max(a, 1))
print(torch.max(a, 1)[1].numpy())

输出结果:

tensor([[ 1,  5, 62, 54],
        [ 2,  6,  2,  6],
        [ 2, 65,  2,  6]])
torch.return_types.max(
values=tensor([62,  6, 65]),
indices=tensor([2, 1, 1]))
[2 1 1]

参考链接
    torch.max()使用讲解
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/786663.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号