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