[Python] Augment MNIST dataset tensorflow

Discussão em 'Python' iniciado por Stack, Agosto 5, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to augment the MNIST dataset. This is what I tried. Can't get any success.

    from tensorflow.examples.tutorials.mnist import input_data
    import tensorflow as tf

    X = mnist.train.images
    y = mnist.train.labels

    def flip_images(X_imgs):
    X_flip = []
    tf.reset_default_graph()
    X = tf.placeholder(tf.float32, shape = (28, 28, 1))
    input_d = tf.reshape(X_imgs, [-1, 28, 28, 1])
    tf_img1 = tf.image.flip_left_right(X)
    with tf.Session() as sess:
    sess.run(tf.global_variables_initializer())
    for img in input_d:
    flipped_imgs = sess.run([tf_img1], feed_dict = {X: img})
    X_flip.extend(flipped_imgs)
    X_flip = np.array(X_flip, dtype = np.float32)
    return X_flip

    flip = flip_images(X)


    What am I doing wrong? I can't seem to figure out.

    Error:

    Line: for img in input_d:
    raise TypeError("'Tensor' object is not iterable.")
    TypeError: 'Tensor' object is not iterable

    Continue reading...

Compartilhe esta Página