def fisher(gmm_npy, v, include='mu'): _check_row_float32(v) n, d = v.shape gmm = _numpy_to_gmm(gmm_npy) assert d == gmm.d flags = 0 if 'mu' in include: flags |= yael.GMM_FLAGS_MU if 'sigma' in include: flags |= yael.GMM_FLAGS_SIGMA if 'w' in include: flags |= yael.GMM_FLAGS_W d_fisher = yael.gmm_fisher_sizeof(gmm, flags) fisher_out = numpy.zeros(d_fisher, dtype=numpy.float32) yael.gmm_fisher(n, yael.numpy_to_fvec_ref(v), gmm, flags, yael.numpy_to_fvec_ref(fisher_out)) return fisher_out
def fisher(gmm_npy, v, include='mu'): _check_row_float32(v) n, d = v.shape gmm = _numpy_to_gmm(gmm_npy) assert d == gmm.d flags = 0 if 'mu' in include: flags |= yael.GMM_FLAGS_MU if 'sigma' in include: flags |= yael.GMM_FLAGS_SIGMA if 'w' in include: flags |= yael.GMM_FLAGS_W d_fisher = yael.gmm_fisher_sizeof(gmm, flags) fisher_out = numpy.zeros(d_fisher, dtype=numpy.float32) yael.gmm_fisher(n, yael.numpy_to_fvec_ref( v), gmm, flags, yael.numpy_to_fvec_ref(fisher_out)) return fisher_out
def flushBuffer(x, y, t): c = int(cnt[x, y, t]) fvs = [] for cutFrom, cutTo, fvSize, gmm, partName in parts: desc = np.ascontiguousarray(buffer[x, y, t, :c, cutFrom:(1 + cutTo)]) fv = yael.fvec_new_0(fvSize) yael.gmm_fisher(c, yael.FloatArray.acquirepointer(yael.numpy_to_fvec(desc)), gmm, flags, fv) fvs.append(yael.fvec_to_numpy(fv, fvSize).flatten()) ndescr[x, y, t] += c cnt[x, y, t] = 0 return np.sqrt(c) * np.hstack(tuple(fvs))
def flushBuffer(x, y, t): c = int(cnt[x, y, t]) fvs = [] for cutFrom, cutTo, fvSize, gmm, partName in parts: desc = np.ascontiguousarray(buffer[x, y, t, :c, cutFrom:(1 + cutTo)]) fv = yael.fvec_new_0(fvSize) yael.gmm_fisher( c, yael.FloatArray.acquirepointer(yael.numpy_to_fvec(desc)), gmm, flags, fv) fvs.append(yael.fvec_to_numpy(fv, fvSize).flatten()) ndescr[x, y, t] += c cnt[x, y, t] = 0 return np.sqrt(c) * np.hstack(tuple(fvs))