评价此页

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) – 密集维度的数量