---
title: SoftMax
description: "沿指定维度计算归一化指数概率分布。"
url: https://www.hikunpeng.com/document/detail/zh/kunpenghpcs/hpckit/devg/KunpengHPCKit_developer_196.html
sourcePath: /source/zh/kunpenghpcs/hpckit/devg/KunpengHPCKit_developer_196.html
indexId: ef2d359a3afca127389416c89f456fb2697791bcb760e70fd6e51cb89ec8805b67
---
# SoftMax

#### 接口功能

沿指定维度计算归一化指数概率分布。


#### 函数原型

```
torch.nn.Softmax(
dim: Optional[int] = None
)
# 或函数式
torch.nn.functional.softmax(
input: Tensor,
dim: int,
dtype: Optional[torch.dtype] = None
) -> Tensor
```


#### 参数说明


**表1 参数说明**

| 参数 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| dim | int | 是 | 计算维度（如dim=1表示对每行计算）。 |
| input | Tensor | 是 | 输入张量（函数式专用）。 |
| dtype | torch.dtype | 否 | 输出数据类型（函数式专用）。 |
