Skip to main content
. 2019 Jun 8;19(11):2605. doi: 10.3390/s19112605
Algorithm 2 K-SVD algorithm
Task: Find the best dictionary to represent the data samples {yi}i=1N, yiϵRN as sparse compositions by solving:
minD,X{YDXF2}subjecttoi,xi0T0.
Initialization: Set the dictionary matrix D(0)ϵRn×K with l2 normalized columns. Set J=1.
Iterations: Repeat until convergence:
  • Sparse coding stage: Use any pursuit algorithm to compute the representation vectors xi for each sample yi by approximating the solution of
    i=1,2,,N,minxi{yiDxi22}subjecttoxi0T0.
  • Dictionary update stage: For each column k=1,2,,K in DJ1,
    • -
      Define the group of samples that use this atom, wk={i|1iN,xTk(i)0}
    • -
      Compute the overall representation error matrix, Ek, by
      Ek=YjkdjxTj
    • -
      Restrict Ek by choosing only the columns corresponding to wk, and obtain EkR.
    • -
      Apply SVD decomposition EkR=UΔVT. Choose the updated dictionary column dk˜ to be the first column of U. Update the coefficient vector xRk to be the first column of V multiplied by Δ(1,1).
  • Set J=J+1.