Menu

Homogeneous kernel chi2 wrong results ?

Leo vala
2019-01-05
2019-01-05
  • Leo vala

    Leo vala - 2019-01-05

    Hello,

    I am trying to see if the chi2 kernel implementation is the same as the VLFeat's one so I did a test with some numbers to see if I get the same numbers when using the HomogeneousKernelMap. It is not the same although the parameters seems to be the same.. Is it something I am doing wrong ?

    Here is the code:

        double[] a = new double[]{1, 2, 3};
    
        HomogeneousKernelMap.KernelType type = HomogeneousKernelMap.KernelType.Chi2;
        double gamma = 1;
        HomogeneousKernelMap.WindowType wintype = HomogeneousKernelMap.WindowType.Rectangular;
        int order = 1;
    
        HomogeneousKernelMap map = new HomogeneousKernelMap(type,gamma, order ,wintype);
    
        DoubleFV fv = new DoubleFV();
        fv.values = a;
    
        double[] destination = new double[3];
        map.evaluate(destination,1,0,3);
    
        DoubleFV result = map.evaluate(fv);
    
        System.err.println("a = 3 --> "+Arrays.toString(destination));
        System.err.println("a = 1,2,3 --> "+Arrays.toString(result.values));
    

    The results are

    a = 3 --> [1.5076127989356203, 0.3495002528547048, 0.8057848435547948]
    a = 1,2,3 --> [0.8704206552992055, 0.5070961910223503, 0.0, 1.2309606956938133, 0.5330287271275459, 0.4797639731738307, 1.5076127989356203, 0.3495002528547048, 0.8057848435547948]

    While in matlab they are

    Code :

    features=vl_homkermap([1,2,3], 1, 'KCHI2', 'gamma',1)

    features=vl_homkermap([3], 1, 'KCHI2', 'gamma',1)

    a = 3 --> [1.4013 0.6493 0.7712]
    a = 1,2,3 -->[ 0.8090 0.5821 0 1.1441 0.7020 0.4299 1.4013 0.6493 0.7712]

    Any ideas ???

    Thank you in advance

     
  • Jonathon Hare

    Jonathon Hare - 2019-01-05

    You found a bug... There was a difference in the computation of the period (due to an error in order in which instance variables in the HomogeneousKernelMap object were being set). I've fixed it: https://github.com/openimaj/openimaj/commit/b584a7babe7540f76e942e1d381d4c554e67eede

    The bug seems to have been very low impact (e.g. caltech101 classification experiments with vlfeat and the broken openimaj version had very similar results), but it's good to have it fixed and get identical output to vlfeat.

     

Anonymous
Anonymous

Add attachments
Cancel





Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.