The matrix product is composition
The topic Vectors, spaces and linear maps showed that every linear map is an matrix and that a linear layer computes . Two questions were left open: how to compute with such maps, and when an equation can be solved for . This topic answers both.
Start with composition. Apply first and second. The result is linear again, so it is a matrix too. We call that matrix the product and define it by
Column of is applied to column of . Entry by entry, row of meets column of :
The inner sizes must match: an matrix times an matrix is .
Order matters. Take the matrix that will run through this topic and one more:
Then , but . "First , then " is a different map from "first , then ". Grouping, on the other hand, is free: , because composition is associative. Transposing reverses the order: .
One consequence for networks: two linear layers with no activation between them are no deeper than one. Without biases, is a single layer with the matrix . That is why every hidden layer is followed by a nonlinearity.