次の方法で共有


DML_ACTIVATION_HARDMAX1_OPERATOR_DESC構造体 (directml.h)

InputTensor の各要素に対して hardmax 関数を実行し、OutputTensor の対応する要素に結果を配置します。

演算子は、指定された入力の各要素のハードマックス (指定した軸に沿った最初の最大値は 1、その他のすべての値は 0) を計算します。

reducedTensor = ReduceArgMax(InputTensor, axes = Axes, axisDirection = DML_AXIS_DIRECTION_INCREASING)
broadcastedTensor = Broadcast the `reducedTensor` to `InputTensor`
for each coordinate in OutputTensor
    if broadcastedTensor[coordinate] == reducedIndexOf(coordinate)   // reducedIndexOf(coordinate) is the index of the coordinate within reduced axes `axes`.
        OutputTensor[coordinate] = 1
    else
        OutputTensor[coordinate] = 0
endfor

ここで ReduceArgMax(input = InputTensor, axis = Axes) は、 reduce 関数として DML_REDUCE_FUNCTION_ARGMAX を使用してDML_REDUCE_OPERATORされます。

重要

この API は、DirectML スタンドアロン再頒布可能パッケージの一部として使用できます ( Microsoft.AI.DirectML バージョン 1.9 以降を参照してください)。 DirectML のバージョン履歴 も参照してください。

構文

struct DML_ACTIVATION_HARDMAX1_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

reduce hardmax を計算する軸の数。 このフィールドは、 Axes 配列のサイズを決定します。

Axes

型: _Field_size_(AxisCount) const UINT*

ハードマックスを減らす軸。 値は、 [0, InputTensor.DimensionCount - 1]範囲内である必要があります。

例示

次の例では、すべて同じ 3 次元入力テンソルを使用しています。

InputTensor: (Sizes:{2, 2, 2}, DataType:FLOAT32)
[
    [
        [  12, 0],
        [-101, 11],
    ],
    [
        [  3,  234],
        [  0, -101],
    ]
]

例 1

AxisCount: 1
Axes: {1}
OutputTensor: (Sizes:{2, 2, 2}, DataType:FLOAT32)
[
    [               // max element in {12, -101} is 12 and in {0, 11} is 11
        [1, 0],
        [0, 1],
    ],
    [               // max element in {3, 0} is 3 and in {234, -101} is 234
        [1, 1],
        [0, 0],
    ]
]

例 2

AxisCount: 1
Axes: {0}
OutputTensor: (Sizes:{2, 2, 2}, DataType:FLOAT32)
[
    [               // max element in {12, 3} is 12, in {0, 234} is 234, in {-101, 0} is 0 and in {11, -101} is 11
        [1, 0],
        [0, 1],
    ],
    [
        [0, 1],
        [1, 0],
    ]
]

例 3

AxisCount: 2
Axes: {0, 2}
OutputTensor: (Sizes:{2, 2, 2}, DataType:FLOAT32)
[
    [               // max element in {12, 0, 3, 234} is 234 and in {-101, 11, 0, -101} is 11
        [0, 0],
        [0, 1],
    ],
    [
        [0, 1],
        [0, 0],
    ]
]

注釈

この演算子は、AxisCount == 1、Axes == の場合の{DimensionCount - 1}と同じです。

可用性

この演算子は 、DML_FEATURE_LEVEL_5_1で導入されました。

Tensor 制約

InputTensorOutputTensor には、同じ DataTypeDimensionCount、および サイズが必要です。

Tensor のサポート

テンソル 優しい サポートされているディメンション数 サポートされているデータ型
インプットテンソル インプット 1 から 8 FLOAT32、FLOAT16
出力テンソル アウトプット 1 から 8 FLOAT32、FLOAT16

要求事項

   
ヘッダ directml.h

こちらも参照ください