8000 FIX Make dict learning loss match the paper by jeremiedbb · Pull Request #19210 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

FIX Make dict learning loss match the paper #19210

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Oct 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions doc/modules/decomposition.rst
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ problem solved is a PCA problem (dictionary learning) with an
.. math::
(U^*, V^*) = \underset{U, V}{\operatorname{arg\,min\,}} & \frac{1}{2}
||X-UV||_{\text{Fro}}^2+\alpha||V||_{1,1} \\
\text{subject to } & ||U_k||_2 = 1 \text{ for all }
\text{subject to } & ||U_k||_2 <= 1 \text{ for all }
0 \leq k < n_{components}

:math:`||.||_{\text{Fro}}` stands for the Frobenius norm and :math:`||.||_{1,1}`
Expand Down Expand Up @@ -513,7 +513,7 @@ dictionary fixed, and then updating the dictionary to best fit the sparse code.
.. math::
(U^*, V^*) = \underset{U, V}{\operatorname{arg\,min\,}} & \frac{1}{2}
||X-UV||_{\text{Fro}}^2+\alpha||U||_{1,1} \\
\text{subject to } & ||V_k||_2 = 1 \text{ for all }
\text{subject to } & ||V_k||_2 <= 1 \text{ for all }
0 \leq k < n_{\mathrm{atoms}}


Expand Down
20 changes: 20 additions & 0 deletions doc/whats_new/v1.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,26 @@

.. currentmodule:: sklearn

.. _changes_1_0_2:

Version 1.0.2
=============

**In Development**

Changelog
---------

:mod:`sklearn.decomposition`
............................

- |Fix| Fixed the constraint on the objective function of
:class:`decomposition.DictionaryLearning`,
:class:`decomposition.MiniBatchDictionaryLearning`, :class:`decomposition.SparsePCA`
and :class:`decomposition.MiniBatchSparsePCA` to be convex and match the referenced
article. :pr:`19210` by :user:`Jérémie du Boisberranger <jeremiedbb>`.


.. _changes_1_0_1:

Version 1.0.1
Expand Down
8 changes: 4 additions & 4 deletions sklearn/decomposition/_dict_learning.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,8 +480,8 @@ def _update_dict(
if positive:
np.clip(dictionary[k], 0, None, out=dictionary[k])

# Projection on the constraint set ||V_k|| == 1
dictionary[k] /= linalg.norm(dictionary[k])
# Projection on the constraint set ||V_k|| <= 1
dictionary[k] /= max(linalg.norm(dictionary[k]), 1)

if verbose and n_unused > 0:
print(f"{n_unused} unused atoms resampled.")
Expand Down Expand Up @@ -1331,7 +1331,7 @@ class DictionaryLearning(_BaseSparseCoding, BaseEstimator):

(U^*,V^*) = argmin 0.5 || X - U V ||_Fro^2 + alpha * || U ||_1,1
(U,V)
with || V_k ||_2 = 1 for all 0 <= k < n_components
with || V_k ||_2 <= 1 for all 0 <= k < n_components

||.||_Fro stands for the Frobenius norm and ||.||_1,1 stands for
the entry-wise matrix norm which is the sum of the absolute values
Expand Down Expand Up @@ -1608,7 +1608,7 @@ class MiniBatchDictionaryLearning(_BaseSparseCoding, BaseEstimator):

(U^*,V^*) = argmin 0.5 || X - U V ||_Fro^2 + alpha * || U ||_1,1
(U,V)
with || V_k ||_2 = 1 for all 0 <= k < n_components
with || V_k ||_2 <= 1 for all 0 <= k < n_components

||.||_Fro stands for the Frobenius norm and ||.||_1,1 stands for
the entry-wise matrix norm which is the sum of the absolute values
Expand Down
0