Example #1
0
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
Example #2
0
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
Example #3
0
parser.add_argument('--tpos', type=int, required=True)
parser.add_argument('--vocab', action='append', nargs=2, required=True)
parser.add_argument('--enablesecondorder', action='store_true')
parser.add_argument('--enablespatiotemporalgrids', action='store_true')

args, unknown = parser.parse_args()

flags = yael.GMM_FLAGS_MU
if args.enablesecondorder:
    flags |= yael.GMM_FLAGS_SIGMA

parts = []
for p in args.vocab:
    cutFrom, cutTo = map(int, p[0].split('-'))
    gmm = yael.gmm_read(open(p[1], 'r'))
    fvSize = yael.gmm_fisher_sizeof(gmm, flags)
    parts.append((cutFrom, cutTo, fvSize, gmm, os.path.basename(p[1])))

    print >> sys.stderr, '%d-%d: {d: %d, k: %d, fvSize: %d}' % (
        cutFrom, cutTo, gmm.d, gmm.k, fvSize)

nx, ny, nt = (1, 3, 2) if args.enablespatiotemporalgrids else (1, 1, 1)
nxyt = nx * ny * nt
mesh = list(itertools.product(range(nx), range(ny), range(nt)))

buffer = np.zeros((nx, ny, nt, 10000, 500), dtype=np.float32)
acc = np.zeros(
    (nx, ny, nt,
     sum([fvSize for cutFrom, cutTo, fvSize, gmm, partName in parts])),
    dtype=np.float32)
cnt = np.zeros((nx, ny, nt), dtype=int)
Example #4
0
parser.add_argument('--tpos', type = int, required = True)
parser.add_argument('--vocab', action = 'append', nargs = 2, required = True)
parser.add_argument('--enablesecondorder', action = 'store_true')
parser.add_argument('--enablespatiotemporalgrids', action = 'store_true')

args, unknown = parser.parse_args()

flags = yael.GMM_FLAGS_MU
if args.enablesecondorder:
	flags |= yael.GMM_FLAGS_SIGMA

parts = []
for p in args.vocab:
	cutFrom, cutTo = map(int, p[0].split('-'))
	gmm = yael.gmm_read(open(p[1], 'r'))
	fvSize = yael.gmm_fisher_sizeof(gmm, flags)
	parts.append((cutFrom, cutTo, fvSize, gmm, os.path.basename(p[1])))
	
	print >> sys.stderr, '%d-%d: {d: %d, k: %d, fvSize: %d}' % (cutFrom, cutTo, gmm.d, gmm.k, fvSize);

nx, ny, nt = (1, 3, 2) if args.enablespatiotemporalgrids else (1, 1, 1)
nxyt = nx * ny * nt
mesh = list(itertools.product(range(nx), range(ny), range(nt)))

buffer = np.zeros((nx, ny, nt, 10000, 500), dtype = np.float32)
acc = np.zeros((nx, ny, nt, sum([fvSize for cutFrom, cutTo, fvSize, gmm, partName in parts])), dtype = np.float32)
cnt = np.zeros((nx, ny, nt), dtype = int)
ndescr = np.zeros_like(cnt)

def flushBuffer(x, y, t):
	c = int(cnt[x, y, t])