sparse.nn.model.MatchingPursuit

class sparse.nn.model.MatchingPursuit(in_features, out_features, solver=BasisPursuitADMM(lambd=0.1, tol=0.0001, max_iters=100))[source]

Bases: Module

Basis Matching Pursuit (ADMM) AutoEncoder neural network for sparse coding.

Parameters
in_featuresint

The num. of input features (X dimension).

out_featuresint

The dimensionality of the embedding vector Z.

solverBasisPursuitADMM

Matching Pursuit solver for the \(Q_1^\epsilon\) problem (see sparse.nn.solver.basis_pursuit_admm()).

See also

sparse.nn.solver.basis_pursuit_admm

Basis Matching Pursuit solver, used in this model

Notes

In overcomplete coding, where sparse representations emerge, out_features >> in_features. If out_features in_features, the encoding representation will be dense.

Methods

forward(x[, lambd])

AutoEncoder forward pass.

normalize_weight()

Normalize the pre-synaptic weight sum to 1.0.

Attributes

lambd

Solver hard/soft threshold \(\lambda\).

forward(x, lambd=None)[source]

AutoEncoder forward pass.

Parameters
x(B, C, H, W) torch.Tensor

A batch of input images.

lambdfloat or None

If not None, a new solver is created with the given lambd to solve this batch x. In this case, the solver statistics won’t be tracked.

Returns
z(B, Z) torch.Tensor

Embedding vectors: sparse representation of x.

decoded(B, C, H, W) torch.Tensor

Reconstructed x from z.

property lambd

Solver hard/soft threshold \(\lambda\).

normalize_weight()[source]

Normalize the pre-synaptic weight sum to 1.0.