def do_train(sess,X_input, Y_input, X_validation, Y_validation):
    ground_truth_tensor_name = 'ground_truth'
    mini_batch_size = 256
    n_train = X_input.shape[0]

    graph = create_graph()

    train_step, cross_entropy = add_final_training_ops(
        graph, len(classes), FLAGS.final_tensor_name,
        ground_truth_tensor_name)

    init = tf.initialize_all_variables()
    sess.run(init)

    evaluation_step = add_evaluation_step(graph, FLAGS.final_tensor_name, ground_truth_tensor_name)

    bottleneck_tensor = graph.get_tensor_by_name(ensure_name_has_port(BOTTLENECK_TENSOR_NAME))
    ground_truth_tensor = graph.get_tensor_by_name(ensure_name_has_port(ground_truth_tensor_name))

    i=0
    epocs = 20
    validation_acc_vector = []
    training_acc_vector  = []
    cross_entropy_vector = []
    for epoch in xrange(epocs):
        shuffledRange = np.random.permutation(n_train)
        y_one_hot_train = encode_one_hot(len(classes), Y_input)
        y_one_hot_validation = encode_one_hot(len(classes), Y_validation)
        shuffledX = X_input[shuffledRange,:]
        shuffledY = y_one_hot_train[shuffledRange]
        for Xi, Yi in iterate_mini_batches(shuffledX, shuffledY, mini_batch_size):
            sess.run(train_step,
                     feed_dict={bottleneck_tensor: Xi,
                                ground_truth_tensor: Yi})

            is_last_step = (i + 1 == FLAGS.how_many_training_steps)
            if (i % FLAGS.eval_step_interval) == 0 or is_last_step:
                train_accuracy, cross_entropy_value = sess.run(
                  [evaluation_step, cross_entropy],
                  feed_dict={bottleneck_tensor: Xi,
                             ground_truth_tensor: Yi})
                validation_accuracy = sess.run(
                  evaluation_step,
                  feed_dict={bottleneck_tensor: X_validation,
                             ground_truth_tensor: y_one_hot_validation})
                print('%s: Step %d: Train accuracy = %.1f%%, Cross entropy = %f, Validation accuracy = %.1f%%' %
                    (datetime.now(), i, train_accuracy * 100, cross_entropy_value, validation_accuracy * 100))
                cross_entropy_vector.append(cross_entropy_value)
                training_acc_vector.append(train_accuracy * 100)
                validation_acc_vector.append(validation_accuracy * 100)
            i+=1
    print("cross entropy vector length is "+str(len(cross_entropy_vector)))

    """ plotting the training accuarcy vs iterations """
    x_ax = np.arange(0,len(cross_entropy_vector))
    fig, ax = plt.subplots(nrows = 1, ncols = 1)
    ax.plot(x_ax, training_acc_vector)
    plt.xlabel('Iterations')
    plt.ylabel('Training Accuracy')
    plt.title('Training Accuracy vs Number of Iterations')
    fig.savefig('training_acc.jpg')
    plt.close(fig)

    """ plotting the validation accuarcy vs iterations """
    x_ax = np.arange(0,len(cross_entropy_vector))
    fig, ax = plt.subplots(nrows = 1, ncols = 1)
    ax.plot(x_ax, validation_acc_vector)
    plt.xlabel('Iterations')
    plt.ylabel('Validation Accuracy')
    plt.title('Validation Accuracy vs Number of Iterations')
    fig.savefig('validation_acc.jpg')
    plt.close(fig)

    """ plotting the cross-entropy error vs iterations """
    x_ax = np.arange(0,len(cross_entropy_vector))
    fig, ax = plt.subplots(nrows = 1, ncols = 1)
    ax.plot(x_ax, cross_entropy_vector)
    plt.xlabel('Iterations')
    plt.ylabel('Cross Entropy value')
    plt.title('Cross Entropy Value vs Number of Iterations')
    fig.savefig('cross_entropy_value.jpg')
    plt.close(fig)

    """ calculating the test_set accuracy """
    test_accuracy = sess.run(
        evaluation_step,
        feed_dict={bottleneck_tensor: X_test_pool3,
                   ground_truth_tensor: encode_one_hot(len(classes), y_test_pool3)})
    print('Final test accuracy = %.1f%%' % (test_accuracy * 100))