# Logistic regression as a 2-layer neural network?

In the Keras documentation, an example states that a 2-layer neural network with 32 input neurons and 16 output neurons combined with a softmax activation on the output layer is equivalent to logistic regression. I haven't seen a formulation of logistic regression involving neurons before and I am having trouble seeing how to show that they are equivalent mathematically. Can anyone explain or point me towards some resources that might help?

• Draw it out. They are right that (assuming the right activation functions) a neural network with no hidden layers is a logistic regression.
– Dave
May 30, 2021 at 17:15
• What they call neurons are literally nodes/features/columns. Eg in your example 32 input neurons means that you have dataset with 32 explanatory variables/columns. And you are using this to predict 16 groups. (ie since you have 16 output neurons). Softmax is the generalization of the logit function when you have more than 2 groups. Do you now understand why this is logistic regression? May 30, 2021 at 17:19

$$p = \text{sigmoid}\left( b + \omega_{blue}x_{blue} + \omega_{red}x_{red} + \omega_{purple}x_{purple} + \omega_{grey}x_{grey} \right)\\ \iff\\ \log\left( \dfrac{ p }{ 1 - p } \right) = b + \omega_{blue}x_{blue} + \omega_{red}x_{red} + \omega_{purple}x_{purple} + \omega_{grey}x_{grey}$$