예제 #1
0
파일: gmm_train.py 프로젝트: gcheron/DT
def main(argv):
    # read in arguments
    args = sys.argv[1:]
    if len(args) > 0 and args[0] in ("--help", "-h"):
        print HELP_USAGE
        return
    assert len(args) == 3, "wrong number of command parameters!"

    featDir = args[0]
    k = int(args[1])
    gmmDir = args[2]

    trainMat = np.load(featDir).astype(np.float32)
    trainNum, featNum = np.shape(trainMat)
    flags = yael.GMM_FLAGS_W
    niter = 20

    gmm = yael.gmm_learn(
        featNum,
        trainNum,
        k,
        niter,
        yael.FloatArray.acquirepointer(yael.numpy_to_fvec(trainMat)),
        1,
        random.randrange(1000000),
        8,
        flags,
    )
    f = open(gmmDir, "w")
    yael.gmm_write(gmm, f)
    del gmm
예제 #2
0
def save_gmm(gmm, filename):
    """ Saves the GMM object to file. """
    with open(filename, 'w') as _file:
        gmm_write(gmm, _file)
예제 #3
0
def save_gmm(gmm, filename):
    """ Saves the GMM object to file. """
    with open(filename, 'w') as _file:
        gmm_write(gmm, _file)