During dropout training every case is run through its own thinned network, and the gradient of that network is what updates the shared weights. A unit that was omitted for a case must receive no update from that case. Compute the loss and the gradients of a one-hidden-layer softmax network when the dropout masks are given.
Implement thinned_backprop(X, y, W1, b1, W2, b2, in_mask, hid_mask).
Inputs
X: shape (N, D); y: integer class labels, shape (N,).W1 (D, H), b1 (H,), W2 (H, K), b2 (K,).in_mask (N, D) and hid_mask (N, H): arrays of 0s and 1s, one row per case (1 = present).Forward pass (no rescaling, as in the paper's training pass):
Output: a tuple (loss, dW1, db1, dW2, db2): the float and the gradients of with the same shapes as the parameters.