快捷鍵

torch.Tensor.sparse_resize_

Tensor.sparse_resize_(size, sparse_dim, dense_dim) Tensor

self 稀疏張量 調整為所需的大小以及稀疏和稠密維度的數量。

注意

如果 self 中指定的元素數量為零,則 sizesparse_dimdense_dim 可以是任何大小和正整數,只要 len(size) == sparse_dim + dense_dim

然而,如果 self 指定了一個或多個元素,則 size 中的每個維度都不得小於 self 的對應維度,sparse_dim 必須等於 self 中的稀疏維度數量,而 dense_dim 必須等於 self 中的稠密維度數量。

警告

如果 self 不是稀疏張量,則會拋出錯誤。

參數
  • size (torch.Size) – 期望的大小。如果 self 是非空的稀疏張量,則期望的大小不能小於原始大小。

  • sparse_dim (int) – 稀疏維度的數量

  • dense_dim (int) – 稠密維度的數量

文件

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources