# Batch Size in ImageDataGenerator

**URL:** <https://community.deeplearning.ai/t/batch-size-in-imagedatagenerator/307627>\
**Category:** Convolutional Neural Networks in TensorFlow\
**Tags:** week-module-1\
**Created:** [April 12, 2023, 4:28am UTC](https://community.deeplearning.ai/t/batch-size-in-imagedatagenerator/307627 "2023-04-12T04:28:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![neha3](https://avatars.discourse-cdn.com/v4/letter/n/45deac/32.png) [@neha3](https://community.deeplearning.ai/u/neha3)\
**Post date:** [April 12, 2023, 4:28am UTC](https://community.deeplearning.ai/t/batch-size-in-imagedatagenerator/307627/1 "2023-04-12T04:28:57Z")

</div>

Hi,

1. How do I decide on the Batch\_size field in the Training vs Validation ImageDataGenerator?

2. Also, in what cases should we define steps\_per\_epoch? If we do not define this, how does the training gets impacted? Also, how to calculate this steps\_per\_epoch?

3. If I have selected batch\_size=32 for a training generator and batch\_size = 10 for validation generator. The steps per epoch for the training and validation generator will be different based on the total samples in training and validation sets. How is it handled during the training?

---

<div class="post-metadata">

**Author:** ![gent.spah](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/gent.spah/32/136423_2.png) [@gent.spah](https://community.deeplearning.ai/u/gent.spah)\
**Post date:** [April 12, 2023, 8:54am UTC](https://community.deeplearning.ai/t/batch-size-in-imagedatagenerator/307627/2 "2023-04-12T08:54:06Z")

</div>

Hello there,

> [@neha3](#):
>
> How do I decide on the Batch\_size field in the Training vs Validation ImageDataGenerator?

The batch size is normally a power of 2 due to the binary system of computers, according to your computing power and its architecture (and optimizer) you can choose a batch size that is relevant to it so you dont overload the processing unit(s). The batch size can be the same for both train and val.

> [@neha3](#):
>
> - Also, in what cases should we define steps\_per\_epoch? If we do not define this, how does the training gets impacted? Also, how to calculate this steps\_per\_epoch?

Step per epoch is defined in case for example you dont want to go through the entire train or val dataset (lets say you want to finish faster), if you dont define it, it does a division per batch size and keeps going till the end.

> [@neha3](#):
>
> If I have selected batch\_size=32 for a training generator and batch\_size = 10 for validation generator. The steps per epoch for the training and validation generator will be different based on the total samples in training and validation sets. How is it handled during the training?

Should not be a problem in term of handling but usually its chosen a power of 2 for speed,
