How can a neural network layer be written as a linear algebra operation Wx + b?

Quick Overview

Explain how a dense neural network layer is an affine map Wx + b followed by an activation, including the shapes of each term and how a batch becomes one matrix multiply. Tests linear algebra basics for deep learning and why stacked layers need a nonlinearity.

How can a neural network layer be written as a linear algebra operation Wx + b?

Role: Data Scientist

Category: Statistics & Math

Difficulty: easy

Interview Round: Other

How can a neural network layer be written as a linear algebra operation `Wx + b`? ```hint Start with one neuron Write the output of a single neuron as a weighted sum of the inputs plus a constant, then stack several neurons on top of each other. ``` ### What a Strong Answer Covers - The affine map followed by an activation, with the shape of every term - What one row of $W$ means and how a single output is computed - How a batch of inputs turns into one matrix multiply - Why the activation is needed, shown by composing two affine layers - How other layer types relate to matrix multiplication, and where that view stops being linear ### Follow-up Questions - How many parameters does a dense layer from 512 inputs to 256 outputs have? - Given the gradient of the loss with respect to the layer's pre-activation output, what are the gradients with respect to $W$, $b$ and $x$? - How can a convolution be written as a matrix multiplication? - Why can the bias be dropped in a dense layer that is followed by batch normalization?

Overview: Explain how a dense neural network layer is an affine map Wx + b followed by an activation, including the shapes of each term and how a batch becomes one matrix multiply. Tests linear algebra basics for deep learning and why stacked layers need a nonlinearity.

General logo
General
Nov 24, 2026
easyData ScientistOtherStatistics & Math
0
0

How can a neural network layer be written as a linear algebra operation Wx + b?

What a Strong Answer Covers Guidance

  • The affine map followed by an activation, with the shape of every term
  • What one row of WW means and how a single output is computed
  • How a batch of inputs turns into one matrix multiply
  • Why the activation is needed, shown by composing two affine layers
  • How other layer types relate to matrix multiplication, and where that view stops being linear

Follow-up Questions Guidance

  • How many parameters does a dense layer from 512 inputs to 256 outputs have?
  • Given the gradient of the loss with respect to the layer's pre-activation output, what are the gradients with respect to WW , bb and xx ?
  • How can a convolution be written as a matrix multiplication?
  • Why can the bias be dropped in a dense layer that is followed by batch normalization?