sparse#
- torchdyno.models.initializers.sparse(shape, density=0.01, values_sampler=None, zero_diagonal=True, seed=None, dtype=torch.float32)[source]#
Sparse random tensor.
- Parameters:
shape (torch.Size) – shape of the tensor.
density (float, optional) – density of the sparse tensor. Defaults to 0.01.
values_sampler (Optional[Callable[..., np.ndarray]], optional) – function to sample values for the sparse tensor. Defaults to None.
zero_diagonal (bool, optional) – whether to zero the diagonal. Defaults to True.
seed (Optional[int], optional) – random seed. Defaults to None.
dtype (dtype)
- Returns:
initialized sparse random tensor.
- Return type:
torch.Tensor