DML_ACTIVATION_SOFTMAX1_OPERATOR_DESC 结构 (directml.h)

InputTensor 执行 softmax 激活函数,将结果放入 OutputTensor 的相应元素中。

For 1-D InputTensor:
// Let x[i] to be the current element in the InputTensor, and j be the total number of elements in the InputTensor
f(x[i]) = exp(x[i]) / sum(exp(x[0]), ..., exp(x[j-1]))

其中 exp(x) 是自然指数函数。

重要

此 API 作为 DirectML 独立可再发行组件包的一部分提供(请参阅 Microsoft.AI.DirectML 版本 1.9 及更高版本。 另请参阅 DirectML 版本历史记录

语法

struct DML_ACTIVATION_SOFTMAX1_OPERATOR_DESC
{
    const DML_TENSOR_DESC* InputTensor;
    const DML_TENSOR_DESC* OutputTensor;
    UINT AxisCount;
    _Field_size_(AxisCount) const UINT* Axes;
};

成员

InputTensor

类型:const DML_TENSOR_DESC*

要从中读取数据的输入张量。

OutputTensor

类型:const DML_TENSOR_DESC*

要向其写入结果的输出张量。

AxisCount

类型:UINT

要计算减少总和的轴数。 此字段确定 Axes 数组的大小。

Axes

类型:_Field_size_(AxisCount) const UINT*

要减少总和的轴。 值必须在 [0, InputTensor.DimensionCount - 1] 范围内。

注解

AxisCount == 1 且 Axes == {DimensionCount - 1} 时,此运算符等效于 DML_ACTIVATION_SOFTMAX_OPERATOR_DESC

可用性

此运算符是在 DML_FEATURE_LEVEL_5_1 中引入的。

张量约束

InputTensorOutputTensor 必须具有相同的 DataTypeDimensionCountSizes

张量支持

张量 种类 支持的维度计数 支持的数据类型
InputTensor 输入 1 到 8 FLOAT32、FLOAT16
OutputTensor 输出 1 到 8 FLOAT32、FLOAT16

要求

   
页眉 directml.h

另请参阅