haldai / LASIN

Combining Logical Abduction and Statistical INduction
6 stars 1 forks source link

Questions with respect to the code. #4

Open d12306 opened 5 years ago

d12306 commented 5 years ago

@haldai ,Hi, is it the org_data.n_cols = 784 or the number of samples? Since I find the armadillo library stores the matrix in a column first order.

haldai commented 5 years ago

Yes, 784 is the dimension of input feature.

d12306 commented 5 years ago

Thanks, Sorry for another question, I am wondering the function in sampler.pl

% stroke to mask
strokes_mask([], Re, Re).
strokes_mask([[]], Re, Re).
strokes_mask([S | Ss], Temp, Masks):-
    stroke_points(S, [], M),
    length(M, LM),
    (LM >= 8 ->
         (append(Temp, [M], Temp1),
          strokes_mask(Ss, Temp1, Masks), !);
     (strokes_mask(Ss, Temp, Masks), !)
    ). 

stroke_points([P], Temp, Re):-
    append(Temp, [P], Re).
stroke_points([P1, P2 | Ps], Temp, Re):-
    line_points(P1, P2, P),
    append(Temp, P, Temp1),
    stroke_points([P2 | Ps], Temp1, Re).

I am wondering the function of this code.

thanks,

haldai commented 5 years ago

Hi, this function can convert the sampled stroke points into connected line segments, which are then used for masking / removing the sampled strokes from the image.

d12306 commented 5 years ago

Thanks, @haldai ,so you use

 for (int j = 0; j < num_mask; j++) {
            Col<double> *mask = str2ptr<Col<double>>(ms[j]);
            Col<double> masked_vector = inst % *mask; 
            patches.push_back(masked_vector);
            delete mask; // only use mask for one time, recollect memory
        }

right? But I am wondering the inuition, like you should focus more on the wrong dimensions? but why you mask them out? It is hard to understand.

haldai commented 5 years ago

The masked line segments (sub-strokes) are sampled from the wrongly re-constructed examples; these "masks" are actually treated as image patches for training the sparse coder. Once a sub-stroke being masked out, the remaining part of the example image will be processed again for sampling other possible sub-strokes.

d12306 commented 5 years ago

Right! Thanks

haldai commented 5 years ago

You're welcome, please feel free to ask any question about the project 😄