private void allocateWeights() { logMath = LogMath.getLogMath(); weights = new float[ngauss]; for (int i = 0; i < ngauss; i++) { setWeight(i, 1f / ngauss); } }
System.exit(1); setWeight(i, Float.parseFloat(ss[2]));
setWeight(i, weights[i] / nT);
/** * extracts ONE gaussian from the GMM * * @param i position * @return gaussian */ public GMMDiag getGauss(int i) { GMMDiag res = new GMMDiag(1, getNcoefs()); System.arraycopy(means[i], 0, res.means[0], 0, getNcoefs()); System.arraycopy(covar[i], 0, res.covar[0], 0, getNcoefs()); res.setWeight(0, 1); res.precomputeDistance(); return res; }
/** * * @param g second GMM for the merge * @param w1 weight of the first GMM for the merge * @return gaussian */ public GMMDiag merge(GMMDiag g, float w1) { GMMDiag res = new GMMDiag(getNgauss() + g.getNgauss(), getNcoefs()); for (int i = 0; i < getNgauss(); i++) { System.arraycopy(means[i], 0, res.means[i], 0, getNcoefs()); System.arraycopy(covar[i], 0, res.covar[i], 0, getNcoefs()); res.setWeight(i, getWeight(i) * w1); } for (int i = 0; i < g.getNgauss(); i++) { System.arraycopy(g.means[i], 0, res.means[ngauss + i], 0, getNcoefs()); System.arraycopy(g.covar[i], 0, res.covar[ngauss + i], 0, getNcoefs()); res.setWeight(ngauss + i, g.getWeight(i) * (1f - w1)); } res.precomputeDistance(); return res; }
public GMMDiag getMarginal(boolean[] mask) { int nc = 0; for (boolean flag : mask) if (flag) nc++; GMMDiag g = new GMMDiag(getNgauss(), nc); int curc = 0; for (int j = 0; j < ncoefs; j++) { if (mask[j]) { for (int i = 0; i < ngauss; i++) { g.setMean(i, curc, getMean(i, j)); g.setVar(i, curc, getVar(i, j)); } curc++; } } for (int i = 0; i < ngauss; i++) { g.setWeight(i, getWeight(i)); } g.precomputeDistance(); return g; }
private void allocateWeights() { logMath = LogMath.getLogMath(); weights = new float[ngauss]; for (int i = 0; i < ngauss; i++) { setWeight(i, 1f / ngauss); } }
System.exit(1); setWeight(i, Float.parseFloat(ss[2]));
setWeight(i, weights[i] / nT);
/** * extracts ONE gaussian from the GMM * * @param i position * @return gaussian */ public GMMDiag getGauss(int i) { GMMDiag res = new GMMDiag(1, getNcoefs()); System.arraycopy(means[i], 0, res.means[0], 0, getNcoefs()); System.arraycopy(covar[i], 0, res.covar[0], 0, getNcoefs()); res.setWeight(0, 1); res.precomputeDistance(); return res; }
/** * * @param g second GMM for the merge * @param w1 weight of the first GMM for the merge * @return gaussian */ public GMMDiag merge(GMMDiag g, float w1) { GMMDiag res = new GMMDiag(getNgauss() + g.getNgauss(), getNcoefs()); for (int i = 0; i < getNgauss(); i++) { System.arraycopy(means[i], 0, res.means[i], 0, getNcoefs()); System.arraycopy(covar[i], 0, res.covar[i], 0, getNcoefs()); res.setWeight(i, getWeight(i) * w1); } for (int i = 0; i < g.getNgauss(); i++) { System.arraycopy(g.means[i], 0, res.means[ngauss + i], 0, getNcoefs()); System.arraycopy(g.covar[i], 0, res.covar[ngauss + i], 0, getNcoefs()); res.setWeight(ngauss + i, g.getWeight(i) * (1f - w1)); } res.precomputeDistance(); return res; }
public GMMDiag getMarginal(boolean[] mask) { int nc = 0; for (boolean flag : mask) if (flag) nc++; GMMDiag g = new GMMDiag(getNgauss(), nc); int curc = 0; for (int j = 0; j < ncoefs; j++) { if (mask[j]) { for (int i = 0; i < ngauss; i++) { g.setMean(i, curc, getMean(i, j)); g.setVar(i, curc, getVar(i, j)); } curc++; } } for (int i = 0; i < ngauss; i++) { g.setWeight(i, getWeight(i)); } g.precomputeDistance(); return g; }