Example #1
0
        if iter % 200 == 0 and iter != 0:
            print rank, '---->', iter
            fff()
            Z, weighted_score, score, s, rec = probe(best_hypotheses, evaluation_data, pr_data, language.estimate_precision_and_recall)
            to_file([[iter, Z, weighted_score, score, s, rec]], name)

        if iter % options.STEPS == 0 and iter != 0:
            size += 12
            if staged: length += 4 * (size % 48 == 0)
            for e in sampler.chains: e.data = get_data(n=size, max_length=length)

        iter += 1

if __name__ == '__main__':
    # ========================================================================================================
    # Process command line arguments
    # ========================================================================================================
    (options, args) = parser.parse_args()

    suffix = time.strftime('_' + options.NAME + '_%m%d_%H%M%S', time.localtime())
    prefix = '../out/simulations/staged/'
    # ========================================================================================================
    # Running
    # ========================================================================================================
    language = AnBn()

    show_info('running staged input case..')
    probe_sampler(lambda: make_hypothesis('AnBn', N=options.N), language, options, prefix + 'staged_out_' + str(rank) + suffix, length=4)

    show_info('running normal input case..')
    probe_sampler(lambda: make_hypothesis('AnBn', N=options.N), language, options, prefix + 'normal_out_' + str(rank) + suffix)
Example #2
0
    # ========================================================================================================
    # Process command line arguments
    # ========================================================================================================
    (options, args) = parser.parse_args()

    suffix = time.strftime('_' + options.NAME + '_%m%d_%H%M%S',
                           time.localtime())
    prefix = '../out/simulations/transfer/'

    # ========================================================================================================
    # Running
    # ========================================================================================================
    language = An()

    show_info('running normal input case..')
    sampler = probe_MHsampler(make_hypothesis('An', terminals=['b']),
                              language,
                              options,
                              prefix + 'without_prior_out_' + str(rank) +
                              suffix,
                              ret_sampler=True)

    show_info('running with input using different letter case..')
    CASE += 1
    language = An(atom='b')
    probe_MHsampler(make_hypothesis('An', terminals=['b']),
                    language,
                    options,
                    prefix + 'with_prior_out_' + str(rank) + suffix,
                    sampler=sampler)
Example #3
0
In this case, we investigate the effect of different observed data distributions on training convergence.
"""

if __name__ == '__main__':
    comm = MPI.COMM_WORLD
    rank = comm.Get_rank()

    # ========================================================================================================
    # Process command line arguments
    # ========================================================================================================
    (options, args) = parser.parse_args()

    suffix = time.strftime('_' + options.NAME + '_%m%d_%H%M%S', time.localtime())
    prefix = '../out/simulations/skewed/'

    # ========================================================================================================
    # Running
    # ========================================================================================================
    language = AnBn()

    show_info('running skewed input case..')
    rec = probe_MHsampler(make_hypothesis('AnBn'), language, options, prefix + 'skewed_out_' + str(rank) + suffix)

    show_info('running normal input case..')
    CASE += 1
    cnt = Counter()
    num = 64.0 * 2 / options.FINITE
    for i in xrange(1, options.FINITE/2+1):
        cnt['a'*i+'b'*i] = num

    rec1 = probe_MHsampler(make_hypothesis('AnBn'), language, options, prefix + 'normal_out' + str(rank) + suffix, data=[FunctionData(input=[], output=cnt)])
Example #4
0
from LOTlib.Projects.FormalLanguageTheory.Model.Hypothesis import make_hypothesis
from LOTlib.Projects.FormalLanguageTheory.Language.An import An
import time
from mpi4py import MPI

register_primitive(flatten2str)

if __name__ == '__main__':
    comm = MPI.COMM_WORLD
    rank = comm.Get_rank()

    # ========================================================================================================
    # Process command line arguments
    # ========================================================================================================
    (options, args) = parser.parse_args()

    suffix = time.strftime('_' + options.NAME + '_%m%d_%H%M%S', time.localtime())
    prefix = '../out/simulations/transfer/'

    # ========================================================================================================
    # Running
    # ========================================================================================================
    language = An()

    show_info('running normal input case..')
    sampler = probe_MHsampler(make_hypothesis('An', terminals=['b']), language, options, prefix + 'without_prior_out_' + str(rank) + suffix, ret_sampler=True)

    show_info('running with input using different letter case..')
    CASE += 1
    language = An(atom='b')
    probe_MHsampler(make_hypothesis('An', terminals=['b']), language, options, prefix + 'with_prior_out_' + str(rank) + suffix, sampler=sampler)
Example #5
0
    # Process command line arguments
    # ========================================================================================================
    (options, args) = parser.parse_args()

    suffix = time.strftime('_' + options.NAME + '_%m%d_%H%M%S',
                           time.localtime())
    prefix = '../out/simulations/nonadjacent/'

    # ========================================================================================================
    # Running
    # ========================================================================================================
    # case 1
    show_info('running predictable input case..')
    language = LongDependency(C=['c'])
    probe_MHsampler(
        make_hypothesis('LongDependency', terminals=['c', 'd', 'e', 'f']),
        language, options, prefix + 'c_long_' + str(rank) + suffix)

    show_info('running predictable input case..')
    CASE += 1
    language = LongDependency(C=['c', 'd', 'e', 'f'])
    probe_MHsampler(
        make_hypothesis('LongDependency', terminals=['c', 'd', 'e', 'f']),
        language, options, prefix + 'cdef_' + str(rank) + suffix)

    # --------------------------------------------------------------------------------------------------------
    # case 2
    show_info('running predictable input case..')
    options.FINITE = 4
    CASE += 1
    language = LongDependency(C=['c', 'd', 'e', 'f'])
Example #6
0
    # ========================================================================================================
    # Process command line arguments
    # ========================================================================================================
    (options, args) = parser.parse_args()

    suffix = time.strftime('_' + options.NAME + '_%m%d_%H%M%S', time.localtime())
    prefix = '../out/simulations/nonadjacent/'

    # ========================================================================================================
    # Running
    # ========================================================================================================
    # case 1
    show_info('running predictable input case..')
    language = LongDependency(C=['c'])
    probe_MHsampler(make_hypothesis('LongDependency', terminals=['c', 'd', 'e', 'f']), language, options, prefix + 'c_long_' + str(rank) + suffix)

    show_info('running predictable input case..')
    CASE += 1
    language = LongDependency(C=['c', 'd', 'e', 'f'])
    probe_MHsampler(make_hypothesis('LongDependency', terminals=['c', 'd', 'e', 'f']), language, options, prefix + 'cdef_' + str(rank) + suffix)

    # --------------------------------------------------------------------------------------------------------
    # case 2
    show_info('running predictable input case..')
    options.FINITE = 4
    CASE += 1
    language = LongDependency(C=['c', 'd', 'e', 'f'])
    probe_MHsampler(make_hypothesis('LongDependency', terminals=['c', 'd', 'e', 'f']), language, options, prefix + 'c_short_' + str(rank) + suffix)