torch.Tensor.set_#
- Tensor.set_(source=None, storage_offset=0, size=None, stride=None) Tensor#
設定底層儲存、大小和步幅。如果
source是一個張量,則self張量將共享相同的儲存,並具有與source相同的尺寸和步幅。在一個張量中對元素的更改將在另一個張量中反映出來。如果
source是一個Storage,則該方法設定底層儲存、偏移量、尺寸和步幅。- 引數
source (Tensor 或 Storage) – 要使用的張量或儲存
storage_offset (int, optional) – 儲存中的偏移量
size (torch.Size, optional) – 期望的尺寸。預設為源的尺寸。
stride (tuple, optional) – 期望的步幅。預設為 C 連續步幅。