Sparse representation solvers for P0- and P1-problems
Python solvers for P0- and P1-problems.
min_z ||z||_0 s.t. ||Az - x|| < eps
min_z ||z||_1 s.t. ||Az - x|| < eps
min_z ||Az - x||^2 + λ||z||_1
where z
is a sparse representation of the input x
, and A
is a dictionary matrix (either fixed or learned).
Documentation is available at https://sparse-representation.readthedocs.io
The theoretical foundations of the implemented functional are in edX course
Sparse Representations in Signal and Image Processing.
sparse.nn
module contains PyTorch implementation of the listed above algorithms.
Reproduce with edX/finproj/project2_all.py
To illustrate an example with a fixed dictionary, we
1) simulate an image x
of size n x n
, constructed with bars;
2) add noise and corrupt the image -> x_noisy
;
3) generate a fixed dictionary matrix A
of size n^2 x m
(m >> n^2
) with random bars as atoms (columns);
4) reconstruct x'
from x_noisy
by seeking the sparsest vector z
such that Az ≈ x
.
Start a Visdom server and run the examples with
$ python -m visdom.server
$ python sparse/examples/basis_pursuit_pytorch.py
Then navigate to localhost:8097 to see the training progress.
The “output sparsity” is the sparsity of the embedding vector from which the original image is reconstructed.
More examples are on http://85.217.171.57:8097. Choose environments with MatchingPursuit
.
$ git clone https://github.com/dizcza/sparse-representation.git
$ cd sparse-representation
$ pip install -e .[extra]
Extra requirements install PyTorch for sparse.nn
module.