Search code examples
pythontensorflowkeras

What is the purpose of 'batch_size' here and how can it be defined for other datasets?


I have been going through this tutorial until these lines:

batch_size = 32
img_height = 180
img_width = 180

train_ds = tf.keras.utils.image_dataset_from_directory(
  data_dir,
  validation_split=0.2,
  subset="training",
  seed=123,
  image_size=(img_height, img_width),
  batch_size=batch_size)

I know what a batch file is, but I don't really understand how it is used here and what the value of batch_size depends on. If the images in the dataset were 32 x 32, how would it be changed?


Solution

  • Batch size is the number of samples (images) loaded at a time to train a model with. So you'd load 32 images at a time and feed them to your model.