Search in sources :

Example 21 with IntVector

use of zemberek.core.collections.IntVector in project zemberek-nlp by ahmetaa.

the class ProductQuantizer method kmeans.

void kmeans(FArray x, FArray c, int n, int d) {
    int[] values = new int[n];
    IntVector perm = new IntVector(values);
    for (int i = 0; i < n; i++) {
        perm.safeSet(i, i);
    }
    perm.shuffle(rng);
    for (int i = 0; i < ksub_; i++) {
        // x -> src
        x.arrayCopy(// src pos
        perm.get(i) * d, // destination
        c, // destination pos
        i * d, // amount of data
        d);
    }
    BArray codes = new BArray(new byte[n]);
    for (int i = 0; i < niter_; i++) {
        Estep(x, c, codes, d, n);
        MStep(x, c, codes, d, n);
    }
}
Also used : IntVector(zemberek.core.collections.IntVector)

Aggregations

IntVector (zemberek.core.collections.IntVector)21 BufferedReader (java.io.BufferedReader)3 ArrayList (java.util.ArrayList)2 ScoredItem (zemberek.core.ScoredItem)2