现在位置: 首页 > PyTorch 教程 > 正文

PyTorch torch.softmax 函数


Pytorch torch 参考手册 Pytorch torch 参考手册

torch.softmax 是 PyTorch 中用于计算逐元素 softmax 函数的函数。

函数定义

torch.softmax(input, dim, dtype=None)

使用示例

实例

import torch

# 计算 softmax
x = torch.tensor([1.0, 2.0, 3.0])
result = torch.softmax(x, dim=0)
print(result)

Pytorch torch 参考手册 Pytorch torch 参考手册