Skip to content
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

FIX SparseCoder set_params works correctly #15236

Conversation

BenjaminBossan
Copy link
Contributor

Fixes a bug with SparseCoder.set_params. One of the consequences
of this bug is that, for instance, grid searching on the dictionary has no effect.

Reference Issues/PRs

The way that SparseCoder was initialized led to a bug so that
set_params on the dictionary had actually no effect. I added a test
that breaks on the current master, and the fix to make the test pass.

What does this implement/fix? Explain your changes.

Any other comments?

BenjaminBossan added 2 commits October 13, 2019 14:18
The way that SparseCoder was initialized led to a bug so that
set_params on the dictionary had actually no effect. I added a test
that breaks on the current master, and the fix to make the test pass.
Copy link
Member

@jnothman jnothman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this.

self.positive_code = positive_code

@property
def n_components(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_set_sparse_coding_params used to set self.n_components as inferred from dictionary. Since that no longer happens, I added the property in case n_components is still required.

@@ -1018,12 +1018,18 @@ def __init__(self, dictionary, transform_algorithm='omp',
transform_n_nonzero_coefs=None, transform_alpha=None,
split_sign=False, n_jobs=None, positive_code=False,
transform_max_iter=1000):
self._set_sparse_coding_params(dictionary.shape[0],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this helper method still used?

@ogrisel
Copy link
Member

ogrisel commented Jul 25, 2020

I believe this was fixed by #17679. Let me close this. Feel free to reopen with more details if you see a specific case that was not handled correctly by the fix in #17679.

@ogrisel ogrisel closed this Jul 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants