# Overview¶

SParse Optimization Research COde (SPORCO) is a Python package for solving optimisation problems with sparsity-inducing regularisation [30]. These consist primarily of sparse coding [11] and dictionary learning [15] problems, including convolutional sparse coding and dictionary learning [45], but there is also support for other problems such as Total Variation regularisation [33] [3], Robust PCA [7], and Plug and Play Priors [40]. The optimisation algorithms in the current version are based on the Alternating Direction Method of Multipliers (ADMM) [6] or on the Fast Iterative Shrinkage-Thresholding Algorithm (FISTA) [4].

In addition to this documentation, an overview of the design and functionality of SPORCO is also available in [49].

## GPU Acceleration¶

GPU accelerated versions of some of the SPORCO solvers are provided within the sporco.cuda and sporco.cupy subpackages. Use of the former requires installation of the SPORCO-CUDA extension package, while the latter requires installation of CuPy [31]. The sporco.cupy subpackage supports a much wider range of problems than sporco.cuda, which only supports four different variants of convolutional sparse coding. However, the sporco.cuda functions are substantially faster than the corresponding functions in sporco.cupy since those in sporco.cuda are implemented directly in CUDA, while those in sporco.cupy use CuPy as a replacement for NumPy.

## Usage Examples¶

Usage examples are available as Python scripts and Jupyter Notebooks.

### Example Scripts¶

A large collection of scripts illustrating usage of the package can be found in the examples directory of the source distribution. These examples can be run from the root directory of the package by, for example

python examples/scripts/sc/bpdn.py


To run these scripts prior to installing the package it will be necessary to first set the PYTHONPATH environment variable to include the root directory of the package. For example, in a bash shell

export PYTHONPATH=\$PYTHONPATH:pwd


from the root directory of the package, or in a Windows Command Prompt shell

set PYTHONPATH=%PYTHONPATH%;C:\path_to_sporco_root


If SPORCO has been installed via pip, the examples can be found in the directory in which pip installs documentation, e.g. /usr/local/share/doc/sporco-x.y.z/examples/.

### Jupyter Notebooks¶

Jupyter Notebook examples are also available. These examples can be viewed online via nbviewer, or run interactively at binder.

## Citing¶

If you use this library for published work, please cite [46] or [49] (see bibtex entries wohlberg-2016-sporco and wohlberg-2017-sporco in docs/source/references.bib in the source distribution). If you use of any of the convolutional sparse representation classes, please also cite any other papers relevant to the specific functionality that is used, e.g. [45], [43], [44], [42], [21].

## Contact¶

Please submit bug reports, comments, etc. to brendt@ieee.org. Bugs and feature requests can also be reported via the GitHub Issues interface.