import tensorflow as tf

                epoch, total_epochs, step, iteration, batch_loss, batch_acc))

            train_loss += batch_loss
            train_acc += batch_acc

            if step % 30 == 0 :
                summary_str = sess.run(summary_op, feed_dict=train_feed_dict)
                summary_writer.add_summary(summary=summary_str, global_step=epoch)
                summary_writer.flush()


        train_loss /= iteration # average loss
        train_acc /= iteration # average accuracy

        train_summary = tf.Summary(value=[tf.Summary.Value(tag='train_loss', simple_value=train_loss),
                                          tf.Summary.Value(tag='train_accuracy', simple_value=train_acc)])

        # test_acc, test_loss, test_summary = Evaluate(sess)

        summary_writer.add_summary(summary=train_summary, global_step=epoch)
        # summary_writer.add_summary(summary=test_summary, global_step=epoch)
        summary_writer.flush()

        # line = "epoch: %d/%d, train_loss: %.4f, train_acc: %.4f, test_loss: %.4f, test_acc: %.4f \n" % (
        #     epoch, total_epochs, train_loss, train_acc, test_loss, test_acc)
        line = "epoch: %d/%d, train_loss: %.4f, train_acc: %.4f \n" % (
            epoch, total_epochs, train_loss, train_acc)        
        print(line)

        with open('./logs_pretrain/logs.txt', 'a') as f:
