Skip to content

Problem with SparseCoder Object, dictionary not assigned #8675

@VasLem

Description

@VasLem

Code

import numpy as np
from sklearn.decomposition import SparseCoder
sparsecoding = SparseCoder(dictionary=np.random.random((4,8)), n_jobs=2)
print(sparsecoding)

Output

SparseCoder(dictionary=None, n_jobs=2, split_sign=False,
      transform_algorithm='omp', transform_alpha=None,
      transform_n_nonzero_coefs=None)

'dictionary' parameter is not assigned, only 'components_'. This causes GridSearchCV function to drop an error when called using a pipeline, with this object inside. :

/opt/anaconda/lib/python3.6/site-packages/sklearn/decomposition/dict_learning.py in __init__(self, dictionary, transform_algorithm, transform_n_nonzero_coefs, transform_alpha, split_sign, n_jobs)
    899                  transform_n_nonzero_coefs=None, transform_alpha=None,
    900                  split_sign=False, n_jobs=1):
--> 901         self._set_sparse_coding_params(dictionary.shape[0],
    902                                        transform_algorithm,
    903                                        transform_n_nonzero_coefs,

AttributeError: 'NoneType' object has no attribute 'shape'

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugModerateAnything that requires some knowledge of conventions and best practices

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions