# Why is mini batch size passed to the shape of placeholders?

**URL:** <https://community.konduit.ai/t/why-is-mini-batch-size-passed-to-the-shape-of-placeholders/3432>\
**Category:** SameDiff\
**Created:** [March 20, 2026, 7:48am UTC](https://community.konduit.ai/t/why-is-mini-batch-size-passed-to-the-shape-of-placeholders/3432 "2026-03-20T07:48:18Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cezar](https://avatars.discourse-cdn.com/v4/letter/c/dc4da7/32.png) [@Cezar](https://community.konduit.ai/u/Cezar)\
**Post date:** [March 20, 2026, 7:48am UTC](https://community.konduit.ai/t/why-is-mini-batch-size-passed-to-the-shape-of-placeholders/3432/1 "2026-03-20T07:48:18Z")

</div>

Maybe a dumb question, but I thought that the dataset object contain mini batches, and batching is handled by the training functiin

---

<div class="post-metadata">

**Author:** ![agibsonccc](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/agibsonccc/32/697_2.png) [@agibsonccc](https://community.konduit.ai/u/agibsonccc)\
**Post date:** [March 20, 2026, 7:56am UTC](https://community.konduit.ai/t/why-is-mini-batch-size-passed-to-the-shape-of-placeholders/3432/2 "2026-03-20T07:56:58Z")

</div>

@Cezar a dataset can be ANYTHING including the full dataset if it’s small enough. The iterator just handles batching. Dataset is what it operates on.

---

<div class="post-metadata">

**Author:** ![Cezar](https://avatars.discourse-cdn.com/v4/letter/c/dc4da7/32.png) [@Cezar](https://community.konduit.ai/u/Cezar)\
**Post date:** [March 20, 2026, 7:57am UTC](https://community.konduit.ai/t/why-is-mini-batch-size-passed-to-the-shape-of-placeholders/3432/3 "2026-03-20T07:57:46Z")

</div>

yes and in samediff why do i pass the minibatch size to the shape parameter in samediff.placeholder?

---

<div class="post-metadata">

**Author:** ![agibsonccc](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/agibsonccc/32/697_2.png) [@agibsonccc](https://community.konduit.ai/u/agibsonccc)\
**Post date:** [March 20, 2026, 8:12am UTC](https://community.konduit.ai/t/why-is-mini-batch-size-passed-to-the-shape-of-placeholders/3432/4 "2026-03-20T08:12:21Z")

</div>

Can you show me a bit more of what you’re doing? Are you following an example? That might help me answer your question a bit. Placeholders can handle variable shapes. MInibatch size is usually for normalization of the gradients during training.

---

<div class="post-metadata">

**Author:** ![Cezar](https://avatars.discourse-cdn.com/v4/letter/c/dc4da7/32.png) [@Cezar](https://community.konduit.ai/u/Cezar)\
**Post date:** [March 20, 2026, 8:18am UTC](https://community.konduit.ai/t/why-is-mini-batch-size-passed-to-the-shape-of-placeholders/3432/5 "2026-03-20T08:18:58Z")

</div>

In all of the same diff examples, I saw that the shape always starts with -1 for mini batch/batch size. I was wondering why that is, why I cannot just put the shape I use directly.

```auto

     //First: Let's create our placeholders. Shape: [minibatch, in/out]
        SDVariable input = sd.placeHolder("input", DataType.FLOAT, -1, nIn);
        SDVariable labels = sd.placeHolder("labels", DataType.FLOAT, -1, 1);

```

---

<div class="post-metadata">

**Author:** ![agibsonccc](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/agibsonccc/32/697_2.png) [@agibsonccc](https://community.konduit.ai/u/agibsonccc)\
**Post date:** [March 20, 2026, 8:19am UTC](https://community.konduit.ai/t/why-is-mini-batch-size-passed-to-the-shape-of-placeholders/3432/6 "2026-03-20T08:19:32Z")

</div>

-1 is just better because it automatically infers the shape based on the first example thrown in.
