快捷方式

torch.Tensor.dim_order

Tensor.dim_order(ambiguity_check=False) tuple[源代码][源代码]

返回唯一确定的整数元组,描述 self 的维度顺序或物理布局。

维度顺序表示维度在内存中的布局方式,从最外层维度到最内层维度。

请注意,维度顺序可能并非总是唯一确定的。如果 ambiguity_check 为 True,则当维度顺序无法唯一确定时,此函数会引发 RuntimeError;如果 ambiguity_check 是内存格式列表,则当张量无法解释为给定的内存格式之一,或者无法唯一确定时,此函数会引发 RuntimeError。如果 ambiguity_check 为 False,它将返回其中一个合法的维度顺序,而不检查其唯一性。否则,它将引发 TypeError。

参数
  • ambiguity_check (boolList[torch.memory_format]) – 用于检查维度顺序歧义的方法。

  • torch.empty (...) –

  • (0

  • 1

  • 2

  • 3)

  • torch.empty

  • (0

  • 2

  • 1

  • 3)

  • torch.empty

  • (0

  • 2

  • 3

  • 1)

  • torch.empty

  • (0

  • 1

  • 2

  • 3)

  • try (>>>) –

  • torch.empty

  • e (... except TypeError as) –

  • print (...) –

  • order (张量没有唯一的维度) –

  • formats. (ambiguity_check 参数必须是 python:bool内存列表) –

  • torch.empty

  • ambiguity_check=[torch.contiguous_format (...) –

  • torch.channels_last]

  • format (... ) # 它可以映射到 contiguous) –

  • (0

  • 1

  • 2

  • 3)

  • try

  • torch.empty

  • e

  • print

  • formats.

警告

dim_order 张量 API 是实验性的,可能会发生更改。

文档

访问 PyTorch 的全面开发者文档

查看文档

教程

获取面向初学者和高级开发者的深入教程

查看教程

资源

查找开发资源并获得您的疑问解答

查看资源