Example #1
0
File: set.py Project: wacabanga/pdt
def main(argv):

    options = handle_options('set', argv)

    mnist_data = load_dataset()
    X_train = mnist_data[0].reshape(-1, 28, 28, 1)
    sfx = gen_sfx_key(('adt', 'nblocks', 'block_size'), options)

    empty_set_args = {'initializer': tf.random_uniform_initializer}
    set_adt, set_pdt = gen_set_adt(X_train,
                                   options,
                                   store_args=options,
                                   is_in_args=options,
                                   size_args=options,
                                   is_empty_args=options,
                                   empty_set_args=empty_set_args,
                                   nitems=options['nitems'],
                                   batch_size=options['batch_size'])

    graph = tf.get_default_graph()
    savedir = mk_dir(sfx)

    path_name = os.path.join(
        os.environ['DATADIR'],
        'graphs',
        sfx,
    )
    tf.train.SummaryWriter(path_name, graph)

    load_train_save(options, set_adt, set_pdt, sfx, savedir)
    push, pop = pdt.call_fns
Example #2
0
def prep_save(sess: Session, save: bool, dirname: str, params_file: str,
              load: bool):
    save_params = {}
    if save or load:
        saver = tf.train.Saver()
    if save is True:
        savedir = mk_dir(dirname=dirname)
        save_params['savedir'] = savedir
        save_params['saver'] = saver = tf.train.Saver()
    if load is True:
        saver.restore(sess, params_file)
    return save_params
Example #3
0
def main(argv):
    global adt, pdt, sess
    options = handle_options('number', argv)
    sfx = gen_sfx_key(('adt', 'template', 'nblocks', 'block_size'), options)
    zero_args = {'initializer': tf.random_uniform_initializer}

    adt, pdt = gen_number_adt(options,
                              number_shape=(10, ),
                              succ_args=options,
                              add_args=options,
                              mul_args=options,
                              encode_args=options,
                              decode_args=options,
                              zero_args=zero_args,
                              batch_size=options['batch_size'])

    savedir = mk_dir(sfx)
    sess = load_train_save(options, adt, pdt, sfx, savedir)
Example #4
0
def main(argv):
    global queue_adt, queue_pdt, sess, X_train, sfx
    options = handle_options('queue', argv)

    mnist_data = load_dataset()
    X_train = mnist_data[0].reshape(-1, 28, 28, 1)
    sfx = gen_sfx_key(('adt', 'nblocks', 'block_size'), options)

    empty_queue_args = {'initializer': tf.random_uniform_initializer}
    queue_adt, queue_pdt = gen_queue_adt(X_train,
                                         options,
                                         enqueue_args=options,
                                         nitems=options['nitems'],
                                         dequeue_args=options,
                                         empty_queue_args=empty_queue_args,
                                         batch_size=options['batch_size'])

    savedir = mk_dir(sfx)
    sess = load_train_save(options, queue_adt, queue_pdt, sfx, savedir)
Example #5
0
def main(argv):
    global adt, pdt, sess, X_train, sfx
    options = handle_options('eqstack', argv)

    mnist_data = load_dataset()
    X_train = mnist_data[0].reshape(-1, 28, 28, 1)
    #sfx = gen_sfx_key(('adt', 'nblocks', 'block_size'), options)
    sfx = gen_sfx_key(('adt', 'nitems'), options)

    empty_eqstack_args = {'initializer': tf.random_uniform_initializer}
    adt, pdt = eqstack_adt(X_train,
                           options,
                           push_args=options,
                           nitems=options['nitems'],
                           pop_args=options,
                           empty_eqstack_args=empty_eqstack_args,
                           batch_size=options['batch_size'])

    savedir = mk_dir(sfx)
    sess = load_train_save(options, adt, pdt, sfx, savedir)
Example #6
0
def main(argv):
    global adt, pdt, sess, X_train, sfx
    options = handle_options('queue', argv)

    mnist_data = load_dataset()
    X_train = mnist_data[0].reshape(-1, 28, 28, 1)
    #sfx = gen_sfx_key(('adt', 'nblocks', 'block_size'), options)
    sfx = gen_sfx_key(('adt', 'nitems'), options)

    empty_queue_args = {'initializer': tf.random_uniform_initializer}
    adt, pdt = queue_adt(X_train,
                         options,
                         push_args=options,
                         nitems=options['nitems'],
                         pop_args=options,
                         empty_queue_args=empty_queue_args,
                         batch_size=options['batch_size'])

    datadir = os.path.join(os.environ['DATADIR'], "pdt")
    savedir = mk_dir(sfx, datadir=datadir)
    options['sfx'] = sfx
    sess = train(adt, pdt, options, savedir, sfx)