Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
689 views
in Technique[技术] by (71.8m points)

python - "Linear dependence in the dictionary" exception in sklearns OMP

I'm using sklearns OrthogonalMatchingPursuit to get a sparse coding of a signal using a dictionary learned by a KSVD algorithm. However, during the fit I get the following RuntimeWarning:

/usr/local/lib/python2.7/dist-packages/sklearn/linear_model/omp.py:391: RuntimeWarning:  Orthogonal matching pursuit ended prematurely due to linear
dependence in the dictionary. The requested precision might not have been met.

  copy_X=copy_X, return_path=return_path)

In those cases the results are indeed not satisfactory. I don't get the point of this warning as it is common in sparse coding to have an overcomplete dictionary an thus also linear dependency within it. That should not be an issue for OMP. In fact, the warning is also raised if the dictionary is a square matrix.

Might this Warning also point to other issues in the application?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The problem was in the data vector y in

omp = OrthogonalMatchingPursuit(n_nonzero_coefs=target_sparsity)
omp.fit(D, y)

It contained numbers with very small magnitude. When I normalize y as well as D the fit works with the expected accuracy.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...