How to choose number of units in a hidden layer?

“25 units in layer 1, 15 units in layer 2, and 1 output unit in layer 3.”

Please if anyone could help me understand how to determine the number of units in hidden layers, why did we choose 25 in the 1st and 15 in the 2nd, and is there a rule for choosing? Thanks in advance.

Experimentation is used to set these parameters.
You want to add as little complexity as is needed to get “good enough” results.
The labs for this week give examples of this type of exerimentation.