Exemplo n.º 1
0
def main(argv=None):
    data.maybe_download_and_extract(FLAGS.data_dir)
    #loop this
    # for i in ["cnn", "small_cnn", "small_cnnact"]:
    #     FLAGS.model = i
    print("THIS IS MODEL:", FLAGS.model)
    train_loop()
Exemplo n.º 2
0
def main(argv=None):
    data.maybe_download_and_extract(FLAGS.data_dir)
    # If cluster configuration flags were provided, save them
    if FLAGS.ps_hosts != '' and FLAGS.worker_hosts != '':
        ps_hosts = FLAGS.ps_hosts.split(",")
        worker_hosts = FLAGS.worker_hosts.split(",")
        cluster_config = {"ps": ps_hosts, "worker": worker_hosts}
        # Save cluster configuration
        with open('cluster.json', 'w') as f:
            json.dump(cluster_config, f)
        print('Cluster configuration saved.')
    else:
        try:
            # Read cluster configuration
            with open('cluster.json', 'r') as f:
                cluster_config = json.load(f)
        except (OSError, IOError) as e:
            print("No cluster configuration found: you need to provide at " \
                  "least once the two lists of ps and worker hosts")
            return

    if FLAGS.job_name == '':
        print('Pass this script a job name (ps or worker) to start a ' \
              'training session.')
        return

    # Create a cluster
    cluster = tf.train.ClusterSpec(cluster_config)

    # Create and start a server for the local task.
    server = tf.train.Server(cluster,
                             job_name=FLAGS.job_name,
                             task_index=FLAGS.task_index)

    if FLAGS.job_name == "ps":
        server.join()
    elif FLAGS.job_name == "worker":
        train.train_loop(cluster=cluster,
                         master=server.target,
                         task_index=FLAGS.task_index)
Exemplo n.º 3
0
def main(argv=None):
    data.maybe_download_and_extract(FLAGS.data_dir)
    train_loop()
Exemplo n.º 4
0
def main(argv=None):
    data.maybe_download_and_extract(FLAGS.data_dir)

    save_weights()
    optimize_model_for_inference()
    perform_inference()