title: How to extract data without label from tensorflow dataset
body: <p>I have a tf dataset called train_ds:</p>
  <pre><code>directory = 'Data/dataset_train'
  
  train_ds = tf.keras.preprocessing.image_dataset_from_directory(
    directory,
    validation_split=0.2,
    subset=&quot;training&quot;,
      color_mode='grayscale',
    seed=123,
    image_size=(28, 28),
    batch_size=32)
  </code></pre>
  <p>This dataset is composed of 20000 images of &quot;Fake&quot; images and 20000 &quot;Real&quot; images and I want to extract X_train and y_train in numpy form from this tf dataset but I have only managed to get the labels out with</p>
  <p><code>y_train = np.concatenate([y for x, y in train_ds], axis=0)</code></p>
  <p>I also tried with this but it doesn't seem like it's iterating through the 20000 images:</p>
  <pre><code>for images, labels in train_ds.take(-1):  
      X_train = images.numpy()
      y_train = labels.numpy()
  </code></pre>
  <p>I really want to extract the images to X_train and the labels to y_train but I can't figure it out!
  I apologize in advance for any mistake I've made and appreciate all the help I can get :)</p>