score:0

According to the following description for map_fn. (https://www.tensorflow.org/api_docs/python/tf/map_fn)

The "map_fn" returns tensor which was manipulated by the function in the parameter "fn". In your case, train_images first dimension number is 6,000. The "map_fn" applied my_map function 6,000 times and return the result. That is why you just saw the result 1 line.

You could check it just print the tf_map.shape for your confirmation.

When you need to print the result do this:

with tf.Session() as sess:
    print(sess.run(tf_map))

score:1

The print in the my_map won't work for printing. Please, test this:

import tensorflow as tf
from keras.datasets import mnist

(train_images, train_labels), (test_images, test_labels) = mnist.load_data()


def my_map(elem):
    #print(elem)
    elem = elem + 1
    return elem


print(train_images.shape)

tf_map = tf.map_fn(fn=my_map, elems=train_images)


with tf.Session() as sess:
    print(sess.run(tf_map[0,0]))