OneHot¶
OneHot - 11¶
版本¶
名称: OneHot (GitHub)
域:
main
起始版本:
11
函数:
False
支持级别:
SupportType.COMMON
形状推断:
True
此版本的运算符自版本 11 起可用。
摘要¶
根据输入生成一个独热(one-hot)张量。输入张量 'indices' 中索引值表示的位置将具有 'on_value',而其他位置将具有 'off_value',其中 'on_value' 和 'off_value' 是作为必需输入参数 'values' 的一部分指定的,'values' 是一个包含两个元素的张量,格式为 [off_value, on_value]。输出张量的秩将比输入张量的秩大一。新增的维度用于独热表示。新增的维度将插入到由 'axis' 指定的位置。如果未指定 'axis',则新增维度将作为最内层维度插入,即 axis=-1。新增维度的大小由必需的标量输入 'depth' 指定。输出张量的类型与输入 'values' 的类型相同。输入张量 'indices' 中值超出范围 [-depth, depth-1] 的任何条目,将在输出张量中生成所有值为 'off_value' 的独热表示。
当 axis = 0 时:output[input[i, j, k], i, j, k] = 1,对于所有 i, j, k,否则为 0。
当 axis = -1 时:output[i, j, k, input[i, j, k]] = 1,对于所有 i, j, k,否则为 0。
属性¶
axis - INT (默认值为
'-1'
)(可选)添加独热表示的轴。默认值:axis=-1。axis=-1 表示新增维度将作为输出张量中最内层/最后一个维度插入。负值表示从后往前计数维度。接受的范围是 [-r-1, r],其中 r = rank(indices)。
输入¶
indices (异构) - T1
包含索引的输入张量。输入张量 'indices' 中值超出范围 [-depth, depth-1] 的任何条目,将在输出张量中生成所有值为 'off_value' 的独热表示。如果 'indices' 为非整数类型,在使用前将转换为 int64。
depth (异构) - T2
包含恰好一个元素的标量或秩为 1 的张量,指定独热张量中的类别数。这也是输出张量中新增的独热维度(由 'axis' 属性指定)的大小。输入张量 'indices' 中的值应在范围 [-depth, depth-1] 内。如果 'depth' 为非整数类型,在使用前将转换为 int64。
values (异构) - T3
包含恰好两个元素的秩为 1 的张量,格式为 [off_value, on_value],其中 'on_value' 用于填充输入张量 'indices' 中指定的位置,'off_value' 用于填充输入张量 'indices' 中未指定的位置。
输出¶
output (异构) - T3
秩比输入张量 'indices' 大一的张量,即 rank(output) = rank(indices) + 1。输出张量元素的 数据类型 与输入 'values' 的类型相同。
类型约束¶
T1 in (
tensor(double)
,tensor(float)
,tensor(float16)
,tensor(int16)
,tensor(int32)
,tensor(int64)
,tensor(int8)
,tensor(uint16)
,tensor(uint32)
,tensor(uint64)
,tensor(uint8)
)将输入约束为仅限数字类型。
T2 in (
tensor(double)
,tensor(float)
,tensor(float16)
,tensor(int16)
,tensor(int32)
,tensor(int64)
,tensor(int8)
,tensor(uint16)
,tensor(uint32)
,tensor(uint64)
,tensor(uint8)
)将输入约束为仅限数字类型。
T3 in (
tensor(bool)
,tensor(complex128)
,tensor(complex64)
,tensor(double)
,tensor(float)
,tensor(float16)
,tensor(int16)
,tensor(int32)
,tensor(int64)
,tensor(int8)
,tensor(string)
,tensor(uint16)
,tensor(uint32)
,tensor(uint64)
,tensor(uint8)
)约束为任何张量类型。
OneHot - 9¶
版本¶
名称: OneHot (GitHub)
域:
main
起始版本:
9
函数:
False
支持级别:
SupportType.COMMON
形状推断:
True
此版本的运算符自版本 9 起可用。
摘要¶
根据输入生成一个独热(one-hot)张量。输入张量 'indices' 中索引值表示的位置将具有 'on_value',而其他位置将具有 'off_value',其中 'on_value' 和 'off_value' 是作为必需输入参数 'values' 的一部分指定的,'values' 是一个包含两个元素的张量,格式为 [off_value, on_value]。输出张量的秩将比输入张量的秩大一。新增的维度用于独热表示。新增的维度将插入到由 'axis' 指定的位置。如果未指定 'axis',则新增维度将作为最内层维度插入,即 axis=-1。新增维度的大小由必需的标量输入 'depth' 指定。输出张量的类型与输入 'values' 的类型相同。输入张量 'indices' 中值超出范围 [0, depth) 的任何条目,将在输出张量中生成所有值为 'off_value' 的独热表示。
属性¶
axis - INT (默认值为
'-1'
)(可选)添加独热表示的轴。默认值:axis=-1。axis=-1 表示新增维度将作为输出张量中最内层/最后一个维度插入。
输入¶
indices (异构) - T1
包含索引的输入张量。这些值必须是非负整数。输入张量 'indices' 中值超出范围 [0, depth) 的任何条目,将在输出张量中生成所有值为 'off_value' 的独热表示。如果 'indices' 为非整数类型,在使用前将转换为 int64。
depth (异构) - T2
包含恰好一个元素的标量或秩为 1 的张量,指定独热张量中的类别数。这也是输出张量中新增的独热维度(由 'axis' 属性指定)的大小。输入张量 'indices' 中的值应在范围 [0, depth) 内。如果 'depth' 为非整数类型,在使用前将转换为 int64。
values (异构) - T3
包含恰好两个元素的秩为 1 的张量,格式为 [off_value, on_value],其中 'on_value' 用于填充输入张量 'indices' 中指定的位置,'off_value' 用于填充输入张量 'indices' 中未指定的位置。
输出¶
output (异构) - T3
秩比输入张量 'indices' 大一的张量,即 rank(output) = rank(indices) + 1。输出张量元素的 数据类型 与输入 'values' 的类型相同。
类型约束¶
T1 in (
tensor(double)
,tensor(float)
,tensor(float16)
,tensor(int16)
,tensor(int32)
,tensor(int64)
,tensor(int8)
,tensor(uint16)
,tensor(uint32)
,tensor(uint64)
,tensor(uint8)
)将输入约束为仅限数字类型。
T2 in (
tensor(double)
,tensor(float)
,tensor(float16)
,tensor(int16)
,tensor(int32)
,tensor(int64)
,tensor(int8)
,tensor(uint16)
,tensor(uint32)
,tensor(uint64)
,tensor(uint8)
)将输入约束为仅限数字类型。
T3 in (
tensor(bool)
,tensor(complex128)
,tensor(complex64)
,tensor(double)
,tensor(float)
,tensor(float16)
,tensor(int16)
,tensor(int32)
,tensor(int64)
,tensor(int8)
,tensor(string)
,tensor(uint16)
,tensor(uint32)
,tensor(uint64)
,tensor(uint8)
)约束为任何张量类型。