コード例 #1
0
ファイル: Search.py プロジェクト: moverlan/LOTlib
    # starting hypothesis -- here this generates at random
    h0 = Utilities.make_h0()

    hyps = TopN(N=options.TOP_COUNT)
    
    hyps.add(lot_iter(MHSampler(h0, data, options.STEPS, trace=False)))

    return hyps


if __name__ == "__main__":
    # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
    # Main running

    if is_master_process():
        display_option_summary(options)
        huge_data = generate_data(options.LARGE_DATA_SIZE)

    # choose the appropriate map function
    argarray = map(lambda x: [x], options.DATA_AMOUNTS * options.CHAINS)

    seen = set()
    for fs in MPI_unorderedmap(run, numpy.random.permutation(argarray)):
        for h in fs.get_all():
            if h not in seen:
                seen.add(h)
                h.compute_posterior(huge_data)

                if h.prior > float("-inf"):
                    print h.prior, \
コード例 #2
0
ファイル: Search.py プロジェクト: pratiksha/LOTlib
    else:
        data_amounts = [options.DATA]

    # ========================================================================================================
    # Load the model specified on the command line
    # ========================================================================================================

    from LOTlib.Examples.ExampleLoader import load_example

    make_hypothesis, make_data = load_example(options.MODEL)

    # ========================================================================================================
    # Run, MPI friendly
    # ========================================================================================================

    if is_master_process():
        display_option_summary(options)

        eval_data = None
        if options.EVAL_DATA > 0:
            eval_data = make_data(options.EVAL_DATA)


    # choose the appropriate map function
    args = list(itertools.product([make_hypothesis],[make_data], data_amounts * options.CHAINS) )

    # set the output codec -- needed to display lambda to stdout
    sys.stdout = codecs.getwriter('utf8')(sys.stdout)

    seen = set()
    for fs in MPI_unorderedmap(run, numpy.random.permutation(args)):
コード例 #3
0
        data_amount) + data[0].word + '.pkl'
    with open(
            'Chains/' + data[0].X + data[0].Y + str(data_amount) +
            data[0].word + '.pkl', 'w') as f:
        pickle.dump(hyps, f)

    return hyps


###################################################################################
# Main Running
###################################################################################

argarray = map(lambda x: [x], options.data_pts * options.chains)

if is_master_process():
    display_option_summary(options)

seen = set()
for fs in break_ctrlc(
        MPI_map(run, numpy.random.permutation(argarray), progress_bar=False)):
    for h in fs.get_all():
        if h not in seen:
            seen.add(h)
            if h.prior > -Infinity:
                print h.prior, \
                    h.likelihood, \
                    h \

        #sys.stdout.flush()
コード例 #4
0
ファイル: Search.py プロジェクト: TerryLew/BinLOTlib
        assert options.DATA > 0, "*** Must specify either data or dmin, dmax, dstep"
        data_amounts = [options.DATA]

    # ========================================================================================================
    # Load the model specified on the command line
    # ========================================================================================================

    from LOTlib.Examples import load_example

    make_hypothesis, make_data = load_example(options.MODEL)

    # ========================================================================================================
    # Run, MPI friendly
    # ========================================================================================================

    if is_master_process():
        display_option_summary(options)

        eval_data = None
        if options.EVAL_DATA > 0:
            eval_data = make_data(options.EVAL_DATA)

    # choose the appropriate map function
    args = list(
        itertools.product([make_hypothesis], [make_data],
                          data_amounts * options.CHAINS))

    # set the output codec -- needed to display lambda to stdout
    sys.stdout = codecs.getwriter('utf8')(sys.stdout)

    seen = set()