Rumelhart, Hinton and Williams (1986) describe back-propagation for any layered network of logistic units in which connections only go upward and may skip intermediate layers. A bias is a weight from an extra unit whose state is always 1. Compute the paper's total error over a set of cases and the derivative of that error with respect to every weight.
Implement backprop_gradients(W, n_inputs, n_outputs, X, D).
Units. The network has N units numbered 0 .. N-1, and W is an N x N array where W[j][i] is the weight from unit to unit (the paper writes it ).
1 .. n_inputs are input units. Their states are set from a row of X.
n_outputs units are the output units.You may rely on: W[j][i] = 0 whenever , whenever is the bias unit or an input unit, and whenever is an output unit (output units feed nothing).
Cases. X has shape (C, n_inputs) and D has shape (C, n_outputs): case sets the inputs to X[c] and wants the output units to take the states D[c] (in unit order). The total error is
Output: a dict {"E": float, "grad": G} where G is an N x N nested list with
G[j][i] summed over all cases, for every non-input, non-bias unit and every (also where the weight happens to be 0). All other entries are 0.0.
W.C is at least 1.