Beispiel #1
0
# op to write logs to Tensorboard
if write_summary:
    summary_writer = tf.summary.FileWriter(params.save_dir, graph=tf.get_default_graph())

if params.shuffle_training:
    data.load_imgs()

# center, curve 50:50%
# data.categorize_imgs()

for i in xrange(params.training_steps):
    if params.use_category_normal:
        txx, tyy = data.load_batch_category_normal('train')
    else:
        txx, tyy = data.load_batch('train')

    # print "txx: ", len(txx), len(txx[0]), len(txx[0][0]),  len(txx[0][0][0])
    # print "tyy: ", tyy

    train_step.run(feed_dict={model.x: txx, model.y_: tyy})

    # write logs at every iteration
    if write_summary:
        summary = merged_summary_op.eval(feed_dict={model.x: txx, model.y_: tyy})
        summary_writer.add_summary(summary, i)

    if (i+1) % 10 == 0:
        if params.use_category_normal:
            vxx, vyy = data.load_batch_category_normal('val')
        else:
Beispiel #2
0
# merge all summaries into a single op
if write_summary:
    merged_summary_op = tf.summary.merge_all()

saver = tf.train.Saver()
time_start = time.time()

# op to write logs to Tensorboard
if write_summary:
    summary_writer = tf.summary.FileWriter(params.save_dir, graph=tf.get_default_graph())

if params.shuffle_training:
    data.load_imgs()

for i in xrange(params.training_steps):
    txx, tyy = data.load_batch('train')

    train_step.run(feed_dict={model.x:txx, model.y_:tyy, model.keep_prob: 0.8})

    # write logs at every iteration
    if write_summary:
        summary = merged_summary_op.eval(feed_dict={model.x: txx, model.y_: tyy, model.keep_prob: 1.0})
        #summary_writer.add_summary(summary, i)

    if (i+1) % 10 == 0:
        vxx, vyy = data.load_batch('val')
        t_loss = loss.eval(feed_dict={model.x: txx, model.y_: tyy, model.keep_prob: 1.0})
        v_loss = loss.eval(feed_dict={model.x: vxx, model.y_: vyy, model.keep_prob: 1.0})
        print "step {} of {}, train loss {}, val loss {}".format(i+1, params.training_steps, t_loss, v_loss)

    if (i+1) % 100 == 0: