# Although I understood the -1 is related to batch size creation for fully connected layers, still a bit confused

**URL:** <https://community.deeplearning.ai/t/although-i-understood-the-1-is-related-to-batch-size-creation-for-fully-connected-layers-still-a-bit-confused/884678>\
**Category:** PyTorch: Techniques and Ecosystem Tools\
**Tags:** week-module-1, dl-ai-learning-platform\
**Created:** [December 8, 2025, 1:40pm UTC](https://community.deeplearning.ai/t/although-i-understood-the-1-is-related-to-batch-size-creation-for-fully-connected-layers-still-a-bit-confused/884678 "2025-12-08T13:40:25Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![paulinpaloalto](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/paulinpaloalto/32/187_2.png) [@paulinpaloalto](https://community.deeplearning.ai/u/paulinpaloalto)\
**Post date:** [December 8, 2025, 11:01pm UTC](https://community.deeplearning.ai/t/although-i-understood-the-1-is-related-to-batch-size-creation-for-fully-connected-layers-still-a-bit-confused/884678/4 "2025-12-08T23:01:21Z")

</div>

> [@Deepti\_Prasad](#):
>
> so basically -1 is only representing here batch size and not dimensions right ?? (I was confused about this)

We are assuming that the first dimension is the “samples” dimension, right? So aren’t they the same thing? Meaning that the size of the first dimension (index 0 in python) is the number of samples. So it’s the size of a dimension. And the -1 just means “use whatever the size is”, meaning that the code works for any batch size.

> [@Deepti\_Prasad](#):
>
> Also in the output you shared, there is no flattening layer output? because that’s where my confusion begins with how that -1 further get calculated

You don’t need to specify the output size, since it’s determined by the sizes of all the dimensions other than the first dimension (samples dimension). So it’s a very nice and general way to write the code.

We can construct some experiments using `torch.Tensor.view` and `torch.flatten`, similar to [this post about numpy](https://community.deeplearning.ai/t/flattening-images-in-the-logistic-regression-assignment-in-course-1-week-2/149) `np.reshape`.

I will play around with this, but it may take me a few hours (have some real life to take care of 😀). Stay tuned!

---

_[View the full topic](https://community.deeplearning.ai/t/although-i-understood-the-1-is-related-to-batch-size-creation-for-fully-connected-layers-still-a-bit-confused/884678)._
