我使用sklearn的OrthogonalMatchingPursuit来对通过KSVD算法学习到的字典进行信号的稀疏编码。然而,在拟合过程中,我收到了以下运行时警告:
/usr/local/lib/python2.7/dist-packages/sklearn/linear_model/omp.py:391: RuntimeWarning: Orthogonal matching pursuit ended prematurely due to lineardependence in the dictionary. The requested precision might not have been met. copy_X=copy_X, return_path=return_path)
在这些情况下,结果确实不尽如人意。我不明白这个警告的意义,因为在稀疏编码中,拥有超完备字典并因此存在线性依赖是很常见的。这不应该成为OMP的问题。事实上,即使字典是一个方阵,也会触发这个警告。
这个警告是否也可能指向应用中的其他问题?
回答:
问题出在数据向量y
中
omp = OrthogonalMatchingPursuit(n_nonzero_coefs=target_sparsity)omp.fit(D, y)
它包含了非常小的数值。当我对y
以及D
进行归一化后,拟合达到了预期的精度。