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