Rate this Page

torch.Tensor.sparse_resize_#

Tensor.sparse_resize_(size,sparse_dim,dense_dim)Tensor#

Resizesselfsparse tensor to the desiredsize and the number of sparse and dense dimensions.

Note

If the number of specified elements inself is zero, thensize,sparse_dim, anddense_dim can be anysize and positive integers such thatlen(size)==sparse_dim+dense_dim.

Ifself specifies one or more elements, however, then eachdimension insize must not be smaller than the correspondingdimension ofself,sparse_dim must equal the numberof sparse dimensions inself, anddense_dim mustequal the number of dense dimensions inself.

Warning

Throws an error ifself is not a sparse tensor.

Parameters
  • size (torch.Size) – the desired size. Ifself is non-emptysparse tensor, the desired size cannot be smaller than theoriginal size.

  • sparse_dim (int) – the number of sparse dimensions

  • dense_dim (int) – the number of dense dimensions