Sparse Approximation by the Generalized Soft-Min Penalty
Project description
sparse-approx-gsm
Python (+ optional CUDA) implementation of Sparse Approximation by the Generalized Soft-Min (GSM) Penalty — a sparse-recovery solver based on the Trimmed Lasso.
Tal Amir, Ronen Basri, Boaz Nadler — The Trimmed Lasso: Sparse Recovery Guarantees and Practical Optimization by the Generalized Soft-Min Penalty. Weizmann Institute of Science.
Install
With CUDA extension:
NVCC=/path/to/nvcc
PYBIND11_DIR=$(python -c "import pybind11; print(pybind11.get_cmake_dir())")
CMAKE_ARGS="-DCMAKE_CUDA_COMPILER=$NVCC -Dpybind11_DIR=$PYBIND11_DIR -DCMAKE_CXX_COMPILER=/usr/bin/g++" \
pip install --no-build-isolation . -v
CPU only (omit CUDA flags):
pip install --no-build-isolation .
--no-build-isolation is needed on conda environments to avoid linker conflicts. See CLAUDE.md for full details.
Usage
from gsm_python import sparse_approx_gsm, SparseApproxGSM, gsm
# High-level solver: min ||Ax - y||_2 s.t. ||x||_0 <= k
x = sparse_approx_gsm(A, y, k, profile='normal')
# GSM function and gradient
mu, theta = gsm(z, k, gamma)
Optional GPU
Install CuPy for the matching CUDA version (e.g. pip install cupy-cuda12x), then pass
a CuPy array to gsm() or use SparseApproxGSM(..., use_gpu=True).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file sparse_approx_gsm-1.0.0.tar.gz.
File metadata
- Download URL: sparse_approx_gsm-1.0.0.tar.gz
- Upload date:
- Size: 2.5 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b814d3f89d156dc7fa1ef0dfba21cb88189f0a9e95b3cadf8f4b1fcafc97665b
|
|
| MD5 |
661724a1c33b3e1a9797b4578c317b3a
|
|
| BLAKE2b-256 |
025688fbdea81a869305dccda19dc725d6e8a8501b958214ec56e49824fa5976
|