快捷方式

expand_right

class tensordict.utils.expand_right(tensor: Tensor, shape: Sequence[int])

在右側擴展張量以符合所需的形狀。

參數:
  • tensor – 要擴展的張量

  • shape – 目標形狀

返回:

具有符合目標形狀的張量。

範例

>>> tensor = torch.zeros(3,4)
>>> shape = (3,4,5)
>>> print(expand_right(tensor, shape).shape)
torch.Size([3,4,5])

文件

存取 PyTorch 的完整開發人員文件

檢視文件

教學

取得初學者和高級開發人員的深入教學

檢視教學

資源

尋找開發資源並獲得問題解答

檢視資源