示例#1
0
def gmm_read(filename):
    gmm = yael.gmm_read(open(filename, "r"))
    gmm_npy = _gmm_to_numpy(gmm) 

    yael.gmm_delete(gmm)    
    return gmm_npy
示例#2
0
parser.add_argument('--ypos', type=int, required=True)
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)
示例#3
0
parser.add_argument('--ypos', type = int, required = True)
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):