giagrad.Tensor.sparse#

Tensor.sparse(sparsity, std=0.01) Tensor[source]#

Fills the 2D Tensor data as a sparse matrix.

Non-zero elements will be drawn from the normal distribution \(\mathcal{N}(0, \text{sigma})\), as described in Deep learning via Hessian-free optimization - Martens, J. (2010).

Parameters:
  • sparsity (float between [0, 1)) – The fraction of elements in each column to be set to zero.

  • std (float) – The standard deviation of the normal distribution used to generate the non-zero values.

Examples

>>> Tensor.empty(3, 5).sparse(sparsity=0.4, std=0.2)