Coffee Roasting Lab - Layer 0 size and number of neurons in layer 1

  1. Layer 1 has 3 neurons/units, but the coffee data only has two features. Can you have more units in layer 1 than input features?

  2. The shading shows that each unit is responsible for a different “bad roast” region. What would happen if there were more neurons? Or less neurons?

Hi @Hokie81

According to first question the Layer 1 can be any number as it isn’t represent input feature …layer 0 is represent input feature like this photo

According to Second Question …

every unit detect different regions …so if you increase number of units every unit will detect small and small different region(detect more complex ) until if you continue increasing number of layer and number of neurons in each layer you will fall in overfitting vice versa your model will suffer from underfitting …so you want to choose the best number of layers and neurons in each layer…

note that first layers of Neural network detect small thing from data or image like edges but if you increase number of layer you will detect complex accurate thing like if you train model on face photo you can detect eyes


Regarding your 2nd question, besides @AbdElRhaman_Fakhry’s explanation, I would suggest you to try it yourself. Change the number of neurons:


Then skip a few cells to run the compile and fit methods


Then extract the weights by running the cell immediately after:


And skip again a few cells to lastly plot the new set of boundaries, and see it for yourself.



Hi @AbdElRhaman_Fakhry ,

Thanks for the clarification re. input features, could I clarify further in the coffee roast example, what are 3 features in layer 1 please?

1 Like

It’s very complex relations so it’s very difficult to imagine what it is but it may be like the color of the coffee after some time of roasting and so on

1 Like