nvidia.dali.fn.transpose#
- nvidia.dali.fn.transpose(__input, /, *, bytes_per_sample_hint=[0], output_layout='', perm=None, preserve=False, transpose_layout=True, device=None, name=None)#
通过基于
perm
参数重新排序维度来转置张量。目标维度
i
从源维度perm[i]
获得。例如,对于具有
HWC
布局的源图像,shape = (100, 200, 3)
,且perm = [2, 0, 1]
,它将生成具有CHW
布局和shape = (3, 100, 200)
的目标图像,并保持以下等式\[dst(x_2, x_0, x_1) = src(x_0, x_1, x_2)\]这等效于
\[dst(x_{perm[0]}, x_{perm[1]}, x_{perm[2]}) = src(x_0, x_1, x_2)\]对于所有有效坐标。
此运算符允许序列输入并支持体积数据。
- 支持的后端
‘cpu’
‘gpu’
- 参数:
__input¶ (TensorList) – 运算符的输入。
- 关键字参数:
bytes_per_sample_hint¶ (int 或 list of int, optional, default = [0]) –
输出大小提示,以每样本字节数为单位。
如果指定,则驻留在 GPU 或分页锁定主机内存中的运算符输出将被预先分配,以适应此大小的样本批次。
output_layout¶ (layout str, optional, default = ‘’) –
显式设置输出数据布局。
如果指定此参数,则忽略
transpose_layout
。perm¶ (int 或 list of int, optional) –
输入维度的排列,例如 [2, 0, 1]。
如果未给出,则维度将反转。
preserve¶ (bool, optional, default = False) – 阻止运算符从图中移除,即使其输出未使用。
transpose_layout¶ (bool, optional, default = True) –
当设置为 True 时,输出数据布局中的轴名称将根据
perm
进行排列。否则,输入布局将复制到输出。如果设置了
output_layout
,则忽略此参数。