luanfujun/deep-photo-styletransfer

wrong CSR format

John-HW-Cao opened this issue · 4 comments

Hi
@luanfujun

The following code in the file deep-photo-styletransfer/gen_laplacian/gen_laplacian.m is really confusing me.

    disp('Save to disk');
    n = nnz(A);
    [Ai, Aj, Aval] = find(A);
    CSC = [Ai, Aj, Aval];
    %save(['Input_Laplacian_3x3_1e-7_CSC' int2str(i) '.mat'], 'CSC');
    
    [rp ci ai] = sparse_to_csr(A);
    Ai = sort(Ai);
    Aj = ci;
    Aval = ai;
    CSR = [Ai, Aj, Aval];
    save(['Input_Laplacian_3x3_1e-7_CSR' int2str(i) '.mat'], 'CSR');
 

The rp variable, which is the signature of the CSR format, is not used at all. So I think maybe the saved .mat file is not a CSR file.

However, you used mate.load.CSR function to load .mat file in lua file

-- load matting laplacian
  local CSR_fn = 'gen_laplacian/Input_Laplacian_'..tostring(params.patch)..'x'..tostring(params.patch)..'_1e-7_CSR' .. tostring(index) .. '.mat'
  print('loading matting laplacian...', CSR_fn)
  local CSR = matio.load(CSR_fn).CSR:cuda()

could you please explain this conflict?

The CSR format is not wrong. The information required for a CSR sparse matrix includes row index, col index and element value, which are all saved as you can see in CSR = [Ai, Aj, Aval].

Actually, a CSR format includes row offsets, column indices and values, which is explained in wikipedia

I don't understand what's your question.

Also, matio.load is just loading a Matlab matrix, not specific to CSR or CSC formats. Next time maybe doublecheck before posting.