Shortcuts

Function torch::nn::init::sparse_

Function Documentation

Tensor torch::nn::init::sparse_(Tensor tensor, double sparsity, double std = 0.01)

Fills the 2D input Tensor as a sparse matrix, where the non-zero elements will be drawn from a centered normal distribution with the given standard deviation std

, as described in “Deep learning via

Hessian-free optimization” - Martens, J.

(2010). The sparsity is a real value between 0 and 1 that controls the fraction of elements in each column to be set to zero. No gradient will be recorded for this operation.

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources