InputTensor의 각 요소에 대해 하드맥스 함수를 수행하여 결과를 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)는 DML_REDUCE_FUNCTION_ARGMAX reduce 함수로 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
계산할 축 수로 하드맥스를 줄입니다. 이 필드는 축 배열의 크기를 결정 합니다 .
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 및 축 == 의 {DimensionCount - 1} 동일합니다.
가용도
이 연산자는 DML_FEATURE_LEVEL_5_1 도입되었습니다.
Tensor 제약 조건
InputTensor 및 OutputTensor 에는 동일한 DataType, DimensionCount 및 크기가 있어야 합니다.
Tensor 지원
| 텐서 | 친절한 | 지원되는 차원 수 | 지원되는 데이터 형식 |
|---|---|---|---|
| 입력 텐서 | 입력 | 1~8 | FLOAT32, FLOAT16 |
| 출력텐서 | 출력 | 1~8 | FLOAT32, FLOAT16 |
요구 사항
| 머리글 | directml.h |