評價此頁

torch.Tensor.set_#

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

設定底層儲存、大小和步幅。如果 source 是一個張量,則 self 張量將共享相同的儲存,並具有與 source 相同的尺寸和步幅。在一個張量中對元素的更改將在另一個張量中反映出來。

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

引數
  • source (TensorStorage) – 要使用的張量或儲存

  • storage_offset (int, optional) – 儲存中的偏移量

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

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