Compute maxout units and which piece won
Why it matters Maxout is a classic learned activation and the argmax is what its backward pass routes gradients through.
A maxout unit takes the max of k linear pieces, so it can learn its own convex activation shape.
Write maxout(x, W, b, k). x is (n, d), W is (d, m * k), b is (m * k,). z = x @ W + b, and unit j owns the k consecutive columns j * k to j * k + k - 1. Return (out, arg): out is (n, m), the max over each unit's k pieces, and arg is (n, m) integer, the winning piece index 0..k-1.
def maxout(x, W, b, k)Example
x = [[1, 2]], W = [[1, 0, -1, 1], [0, 1, 1, -1]], b = [0, 0, 0, 0], k = 2 gives out [[2, 1]] and arg [[1, 0]].
Understand the idea
A maxout unit computes several straight lines and keeps the highest one at each input. The upper edge of several lines can bend into any convex shape: two lines y = x and y = 0 give ReLU, y = x and y = -x give the absolute value. Like choosing the best of several quotes for each job.
Tiny example: x = [1, 2]. Unit 1 has pieces x1 = 1 and x2 = 2, max 2 from piece 1. Unit 2 has pieces -x1 + x2 = 1 and x1 - x2 = -1, max 1 from piece 0.
Rule: z = xW + b, reshape to (n, m, k), out = max over k. In the backward pass only the winning piece gets the gradient.
Maxout was popular with dropout for image classification and is a good example of a learned activation.
Shapes and data flow
x (n,d) @ W (d, m*k) -> z (n, m*k) -> (n, m, k) -> out, arg (n, m)