adding summary to tensorflow model error I have a CNN model for classifying lung CT images, the code is written in tensorflow, I added some tensorflow summaries to my code to show graph, scalar, histogram, ... of my tensorflow model in tensorboard, in last step when I want to add_summary to the file writer it gives me an error, here is my code:

def train_CNN(input):
    train_predict = CNN_Model(x_img)
    with tf.name_scope("cross_entropy"):
        cost = tf.nn.softmax_cross_entropy_with_logits_v2(logits=train_predict, labels=y_label, name='cross_entropy')
        cost = tf.reduce_mean(cost, name='reduce_mean')
        tf.summary.scalar("cost", cost)
    with tf.name_scope("optimization"):
        optimizer = tf.train.AdamOptimizer(learning_rate, name='AdamOptimizer').minimize(cost)

    with tf.name_scope("accuracy"):
        correct_predict = tf.equal(tf.argmax(train_predict, 1), tf.argmax(y_label, 1))
        accuracy = tf.reduce_mean(tf.cast(correct_predict, tf.float32))
        tf.summary.scalar("accuracy", accuracy)

    #tf.summary.image("input", x_img, 5)

    sess.run(tf.global_variables_initializer())
    log_train_path = 'C:/temp/tensorflow_logs' + '/train_{}'.format(datetime.now().strftime("%Y-%m-%d-%H%M%S"))   
    summary_writer = tf.summary.FileWriter(log_train_path)
    summary_writer.add_graph(sess.graph)
    merged_summary = tf.summary.merge_all()

    all_time = 0

    for epoch in range(num_epochs):
        start_time = time.time()
        ep_loss = 0
        for data in train_data:
            X = data[0]
            Y = data[1]
            summary, _, c = sess.run([merged_summary, optimizer, cost], feed_dict={x_img: X, y_label: Y})
            ep_loss += c
            summary_writer.add_summary(summary, epoch)
        end_time = time.time()
        all_time += int(end_time-start_time)
        print('Epoch', epoch+1, 'completed out of',num_epochs,'loss:',ep_loss, 'time usage: '+str(int(end_time-start_time))+' seconds')

        print('Accuracy of this epoch:',accuracy.eval({x_img:[i[0] for i in val_data], y_label:[i[1] for i in val_data]}))

    print('Finall Accuracy:',accuracy.eval({x_img:[i[0] for i in val_data], y_label:[i[1] for i in val_data]}), 'time usage: '+str(all_time)+' seconds')


after running the model it give me error, can anyone tell me how to solve it?

here is the error:

InvalidArgumentError: Expected dimension in the range [-1, 1), but got 1
     [[Node: accuracy/ArgMax_1 = ArgMax[T=DT_FLOAT, Tidx=DT_INT32, output_type=DT_INT64, _device="/job:localhost/replica:0/task:0/device:CPU:0"](_arg_y_label_0_1, accuracy/ArgMax_1/dimension)]]
Check out dimension

 X = data[0]
 Y = data[1]


Its likely that have dimensions like (1, ) what means that's 1 dim vector.

That should be work

import numpy as np
X = np.array(X).reshape(-1,1)
Y = np.array(Y).reshape(-1,1)