borelliCDL is a Python library for convolutional dictionary learning applied to signal processing. It integrates alphacsc but lets you control the dictionary update step, allowing flexibility in choosing solvers. It also tracks the number of iterations during dictionary updates, so you can analyze solver performance.
- Custom Dictionary Update: Uses a specific function (
my_update_d) to update the dictionary, compatible with solvers likelsmr,lsqr,cg, etc. - Signal Reconstruction: Allows reconstructing signals from learned atoms and activations.
- Direct Integration with alphacsc: Uses
alphacsc.learn_d_zwhile keeping full control over the dictionary update process. - Tracks Iterations: Returns the number of iterations required for convergence.
Clone the repo and install manually:
git clone https://github.com/yourusername/borelliCDL.git
cd borelliCDL
pip install .Or install directly with pip:
pip install git+https://github.com/yourusername/borelliCDL.gitHere’s a quick example to learn a dictionary and reconstruct signals:
import numpy as np
from borelliCDL import fit_D_Z, reconstructMySignal
Y = np.random.randn(3, 1000) #3 signals of length T= 1000
#Dictionary learning hyper-parameters
n_atoms = 5
n_times_atom = 350
reg = 0.045
n_iter = 3
#Learn the dictionary and activations to fit the signals
pobj, times, d_hat, z_hat, reg, iteration_count = fit_D_Z(Y, n_atoms, n_times_atom, reg, n_iter)
#Reconstruct the signals to visualize them
reconstructed_signals = reconstructMySignal(d_hat, z_hat)
#Print results
print("Objective:", pobj)
print("Computation times:", times)
print("Iteration count:", iteration_count)
print("Reconstructed signals shape:", reconstructed_signals.shape)- Python 3.6+
- numpy
- scipy
- matplotlib
- numba
- alphacsc
- pandas
If you want to improve the code or add new features, open an issue or submit a pull request.
MIT License.