torch.Tensor.sparse_resize_
- Tensor.sparse_resize_(size, sparse_dim, dense_dim) → Tensor
-
将
self
稀疏张量调整为所需大小,并确定稀疏和密集维度的数量。注意
如果
self
中指定的元素数量为零,则size
、sparse_dim
和dense_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) – 表示稠密维度数量的整数
-