捷徑

torch.Tensor.set_

Tensor.set_(source=None, storage_offset=0, size=None, stride=None) Tensor

設定底層儲存、大小和步幅。如果 source 是一個 tensor,則 self tensor 將共享相同的儲存,並具有與 source 相同的大小和步幅。對一個 tensor 中元素所做的變更將反映在另一個 tensor 中。

如果 source 是一個 Storage,則該方法會設定底層儲存、偏移、大小和步幅。

參數
  • source (TensorStorage) – 要使用的 tensor 或 storage。

  • storage_offset (int, optional) – storage 中的偏移量 (offset)。

  • size (torch.Size, optional) – 期望的尺寸 (size)。預設為 source 的尺寸。

  • stride (tuple, optional) – 期望的步幅 (stride)。預設為 C-contiguous 步幅。

文件

獲取 PyTorch 的完整開發者文件

查看文件

教學

取得針對初學者和進階開發者的深度教學

查看教學

資源

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

查看資源