For and , the Kronecker product is the block matrix whose block is . Let stack the columns of into one vector (column-major, C.reshape(-1, order="F")). Implement three functions from Murphy's book. None of them may build a Kronecker product: tests use factors, whose Kronecker product would need about 13 GB.
kron_matvec(A, B, C): return as a 1-D array of length , for C of shape (q, n), using the identity .
kron_solve(A, B, y): for square invertible A () and B () and a 1-D y of length , return the 1-D x with , using . Use solves with the factors, not inverses of the big matrix.
bow_logits(S, W, V): a bag-of-words classifier. S has shape (N, T, K) (one-hot words of sequences of length ), W shape (K, D) (embeddings), V shape (D, C) (classifier). Return the (N, C) logits , computed with a single np.einsum call.