Sparse Coding

dictlearn.methods._omp.omp(Y, D, n_nonzero_coefs)

Orthogonal Matching Pursuit wrapper

Parameters:
  • Y (ndarray of shape (n_features, n_samples)) – Data matrix.

  • D (ndarray of shape (n_features, n_components)) – Initial dictionary, with normalized columns.

  • n_nonzero_coefs (int, default=None) – Desired number of non-zero entries in the solution. If None (by default) this value is set to 10% of n_features.

Returns:

  • X (ndarray of shape (n_components, n_samples)) – The sparse codes.

  • err (float) – The approximation error

Example:

X, err = omp(Y, D, n_nonzero_coefs)
dictlearn.methods._omp.omp_2d(Y, D, n_nonzero_coefs)

Orthogonal Matching Pursuit 2D wrapper

Parameters:
  • Y (ndarray of shape (n_features, n_samples)) – Data matrix.

  • D (ndarray of shape (n_components, n_features)) – The dictionary matrix against which to solve the sparse coding of the data. Some of the algorithms assume normalized cols.

  • n_nonzero_coefs (int, default=None) – Desired number of non-zero entries in the solution. If None (by default) this value is set to 10% of n_features.

Returns:

  • X (ndarray of shape (n_components, n_samples)) – The sparse codes.

  • err (float) – The approximation error

Example:

X, err = omp_2d(Y, D, n_nonzero_coefs)
dictlearn.methods._omp.omp_postreg(Y, D, X, mu)

Post Orthogonal Matching Pursuit regularization. Solve regularized least squares problem on support computed by OMP or other sparse encoder.

Parameters:
  • Y (ndarray of shape (n_features, n_samples)) – Data matrix.

  • D (ndarray of shape (n_features, n_components)) – The dictionary matrix against which to solve the sparse coding of the data. Some of the algorithms assume normalized cols.

  • X (ndarray of shape (n_components, n_samples)) – The sparse codes.

  • mu (float) – The regularization factor

Returns:

X – The sparse codes.

Return type:

ndarray of shape (n_components, n_samples)

Example:

X = omp_postreg(Y, D, X, mu)
dictlearn.methods._omp.ker_omp_postreg(K, A, X, mu)

Post Kernel Orthogonal Matching Pursuit regularization. Solve regularized least squares problem on support computed by OMP or other sparse encoder.

Parameters:
  • K (ndarray of shape (n_samples, n_samples)) – Kernel matrix.

  • A (ndarray of shape (n_samples, n_components)) – The dictionary matrix against which to solve the sparse coding of the data. Some of the algorithms assume normalized cols.

  • X (ndarray of shape (n_components, n_samples)) – The sparse codes.

  • mu (float) – The regularization factor

Returns:

X – The sparse codes.

Return type:

ndarray of shape (n_components, n_samples)

Example:

X = ker_omp_postreg(K, A, X, mu)