# Number of units and layers in neural network

**URL:** <https://community.deeplearning.ai/t/number-of-units-and-layers-in-neural-network/229877>\
**Category:** Advanced Learning Algorithms\
**Tags:** week-module-1\
**Created:** [November 12, 2022, 3:21pm UTC](https://community.deeplearning.ai/t/number-of-units-and-layers-in-neural-network/229877 "2022-11-12T15:21:25Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jiatong\_xu](https://avatars.discourse-cdn.com/v4/letter/j/d07c76/32.png) [@jiatong\_xu](https://community.deeplearning.ai/u/jiatong_xu)\
**Post date:** [November 12, 2022, 3:21pm UTC](https://community.deeplearning.ai/t/number-of-units-and-layers-in-neural-network/229877/1 "2022-11-12T15:21:25Z")

</div>

Take house price as example, how we can choose number of units and layers? I am not sure about this, somebody help.

---

<div class="post-metadata">

**Author:** ![Juan\_Olano](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/juan_olano/32/27125_2.png) [@Juan\_Olano](https://community.deeplearning.ai/u/Juan_Olano)\
**Post date:** [November 12, 2022, 3:24pm UTC](https://community.deeplearning.ai/t/number-of-units-and-layers-in-neural-network/229877/2 "2022-11-12T15:24:20Z")

</div>

Hi @jiatong_xu ,

Welcome to the community! This is your first post 🙂

Regarding your question: “How we can choose number of units and layer”, I’d like to share with you [another post](https://community.deeplearning.ai/t/of-nodes-in-a-layer/229331/2) where this exact question is answered:

> [@\# of nodes in a layer](https://community.deeplearning.ai/t/of-nodes-in-a-layer/229331/2):
>
> Hi @lzednik , The number of nodes, and even the hidden layers, are determined by the architect of the NN: by you, by me, by the person or group that is creating the NN. There are several options: You can get started with a known model which has been created by some researchers, and this model proposes already a certain amount of layers, and nodes inside of each layer. You can start from scratch. 2.1 Assuming you are a very experienced ML designer, may be you’ll get started with a configurat…

Please read that post and let me know if this clarifies your question.

Thanks!

Juan

---

<div class="post-metadata">

**Author:** ![rmwkwok](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/rmwkwok/32/126977_2.png) [@rmwkwok](https://community.deeplearning.ai/u/rmwkwok)\
**Post date:** [February 1, 2023, 3:09am UTC](https://community.deeplearning.ai/t/number-of-units-and-layers-in-neural-network/229877/3 "2023-02-01T03:09:29Z")

</div>

Moved this thread to MLS course 2 week 1.

---

<div class="post-metadata">

**Author:** ![Edwin\_Shajan](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/edwin_shajan/32/38640_2.png) [@Edwin\_Shajan](https://community.deeplearning.ai/u/Edwin_Shajan)\
**Post date:** [February 9, 2023, 5:54pm UTC](https://community.deeplearning.ai/t/number-of-units-and-layers-in-neural-network/229877/4 "2023-02-09T17:54:25Z")

</div>

is there any technique to find the right number of layers and units? Or we can only find it by changing after we get an output?

---

<div class="post-metadata">

**Author:** ![Juan\_Olano](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/juan_olano/32/27125_2.png) [@Juan\_Olano](https://community.deeplearning.ai/u/Juan_Olano)\
**Post date:** [February 9, 2023, 8:45pm UTC](https://community.deeplearning.ai/t/number-of-units-and-layers-in-neural-network/229877/5 "2023-02-09T20:45:07Z")

</div>

I’d say that there’s not a specific technique to find the right number of layers and units. It will depend on the specific case at stake. Experience will be one source, and other similar models can be another source, but definitively, the experimentation with your model is the best source for that.

And may be if we want to define a technique, then it could be this: Fast iteration. Prof Ng mentions this in several points of the lessons in his specializations.

**Come up with a model and run it. Quickly. And learn, and fine tune and run it again, and repeat this until you reach your objective.**

So yes, that would be the ‘technique’. 🙂
