bwohlberg / sporco

Sparse Optimisation Research Code
http://brendt.wohlberg.net/software/SPORCO/
BSD 3-Clause "New" or "Revised" License
261 stars 37 forks source link

Non-negative dictionary constraint #33

Closed jingxiaoliu closed 5 months ago

jingxiaoliu commented 5 months ago

Hello,

Thank you for providing open access to this excellent implementation of convolutional dictionary learning.

I would like to know if sporco.dictlrn.cbpdndl supports non-negative dictionary constraint. If it does not, could you please provide any insights on how to impose this constraint?

Best regards, Jingxiao

bwohlberg commented 5 months ago

There is support for non-negative coefficients, but no direct support for a non-negative dictionary. It should be relatively straightforward to implement though. Instead of using sporco.dictlrn.cbpdndl, use sporco.dictlrn.dictlrn.DictLearn, which allows one to specify the solvers for the sparse coding and dictionary update steps, as illustrated in this example script. Use one of the standard sparse coding solvers, and create your own custom dictionary update solver, which will just involve deriving a new class from one of the existing ones (e.g. sporco.admm.ccmod.ConvCnstrMOD_Consensus), overriding the ystep method to include a projection onto the non-negative orthant.