# Single layer neural network as linear regression

I'm really struggling to see the analogy between linear regression and a single layer perceptron. They are supposedly the same thing.

I completely understand the concept of the inputs to the neuron being the explanatory variables, and having weights applied to them which are the $$\beta$$ coefficients, as well as the "bias" term which is the intercept in normal regression terms.

Mostly my problem is that I don't understand 1) whether the data is "fed in" to the neural network one data point at a time or all at once, and 2) whether an iterative method is used to find the $$\beta$$ coefficients or if it's just least squares. If an iterative method is used, that introduces the whole gradient descent thing. But when people say a single layer neural network and linear regression are the same thing, are they getting into backpropagation at all? Or are they just saying you can "view" regression in that way, and just minimize the loss function in the normal OLS way?

I hope I'm making at least some sense. Any help is really appreciated.

• “when people say they are the same thing”—What does “they” refer to here? Iterative methods and GD? Oct 18, 2021 at 17:35
• Doing gradient descent for linear regression with OLS errors with Newton's method for example produces exactly the closed form estimator, see this answer. Oct 18, 2021 at 17:36
• As for 1), I believe this answer varies a lot. Generally no, data isn't fed it one-by-one, but I know that a lot of practitioners use minibatching, where subsets of the data are used for each update of the weights and bias. For 2), it doesn't really matter what method you use to find the coefficients, because you're optimising the same function in either case. Theoretically you could find a closed form estimator for a neural network and use that to find the same solution as using gradient descent; the model is still the same. Oct 18, 2021 at 17:40
• They mean that they can configure the network so that it produces exactly the same result as OLS Oct 18, 2021 at 17:41
• @AryaMcCarthy edited, basically meant single layer NN = linear regression Oct 18, 2021 at 17:52

• Linear regression is

$$y = \mathbf{x} \cdot \boldsymbol{w} + b$$

that’s exactly the same as a single-layer network with linear activation.

• Linear regression is usually trained using ordinary least squares, but alternatively you could use an optimization algorithm such as gradient descent.

• Same as with other neural networks, gradient descent can be used for all data, in mini-batches, or one sample at a time (stochastic gradient descent).

• It’s just single layer, so you don’t need back propagation.

• Thanks for the answer. So the neural network itself is basically independent of the method of training? Like how the general regression equation $y = \mathbf{x} \cdot \boldsymbol{w} + b$ is independent from the method you choose to estimate the weights? Oct 18, 2021 at 17:57
• @fmtcs yes, unless you call it “OLS” because then you mean particular method of training as well.
– Tim
Oct 18, 2021 at 17:58
• Note that if N > p, OLS and gradient descent will find the same answer, though gradient descent will be slow. Batch gradient descent will bounce around the OLS solution, though maybe with some learning rate decay it will converge to OLS solution, I'm not sure. Oct 18, 2021 at 18:18
• @JonnyLomond Yes, by managing the learning rate it is possible to guarantee convergence, for example by shortening steps as necessary to achieve a sufficient reduction in global error on each step. Convergence of Rprop and variants Oct 18, 2021 at 19:06