MarvinTeichmann / tensorflow-fcn

An Implementation of Fully Convolutional Networks in Tensorflow.
MIT License
1.1k stars 433 forks source link

Network seems not connected in Tensorboard #30

Closed JayCHaos closed 7 years ago

JayCHaos commented 7 years ago

Hi Marvin,

Thanks for your great code!

I tried training your FCN, but ended up finding some confused things.

The first thing is during the training, the accuracy started from a low value, for example 0.3, and then jumped to over 0.9, but in fact the final trained model (having accuracy around 0.95) does not work that well. By the way, I am doing 2 classes classification (including background).

Another thing is that in Tensorboard, the 'graph' of the network seems not connected (as the following diagram shown). And the other tags are empty, even the 'scalar' and 'histogram'. Maybe I did something improperly.

screenshot from 2017-06-06 16 52 30

The core part of my training script is attached here (I did not touch your script fcn8_vgg.py).

train_imgs, train_labels, test_imgs, test_labels = split_dataset(imgs, labels)

x = tf.placeholder(tf.float32, [None, 64, 48, 3])
y = tf.placeholder(tf.int64, [None, 64, 48, 2])

vgg_fcn = fcn8_vgg.FCN8VGG()
with tf.name_scope("content_vgg"):
    vgg_fcn.build(x, True, 2, True, True)

cross_entropy = loss(vgg_fcn.upscore32, y, 2)
train_step = tf.train.AdamOptimizer(1e-6).minimize(cross_entropy)

correct_prediction = tf.equal(vgg_fcn.pred_up, tf.argmax(y, dimension = 3))
accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))

saver = tf.train.Saver()

with tf.Session() as sess:
    sess.run(tf.global_variables_initializer())

    for i in range(2000):
        training_batch = get_batch(train_imgs, train_labels)
        imgs_train_batch = training_batch['X']
        labels_train_batch = training_batch['Y']

        if i % 100 == 0:
            train_accuracy = accuracy.eval(feed_dict={x: imgs_train_batch, y: labels_train_batch})
            test_accuracy = accuracy.eval(feed_dict={x: test_imgs, y: test_labels})
            print (train_accuracy)
            print('step %d | training accuracy %g | test accuracy %g' % (i, train_accuracy, test_accuracy))
            file_writer = tf.summary.FileWriter(log_dir, sess.graph)

        if i % 1000 == 0:
            save_path = saver.save(sess, bestcheck_dir+'%04d'%(test_accuracy*10000))

        train_step.run(feed_dict={x: imgs_train_batch, y: labels_train_batch})

thanks in advance,

Jay