

def make_nn_funs(layer_sizes, L2_reg):
    shapes = zip(m[:(- 1)], layer_sizes[1:])
    N = sum((((m + 1) * n) for (m, n) in shapes))

    def unpack_layers(W_vect):
        for (m, n) in shapes:
            (yield (W_vect[:(m * n)].reshape((m, n)), W_vect[(m * n):((m * n) + n)]))
            W_vect = W_vect[((m + 1) * n):]

    def predictions(W_vect, inputs):
        for (W, b) in unpack_layers(W_vect):
            outputs = (np.dot(inputs, W) + b)
            inputs = np.tanh(outputs)
        return (outputs - logsumexp(outputs, axis=1, keepdims=True))

    def loss(W_vect, X, T):
        log_prior = ((- L2_reg) * np.dot(W_vect, W_vect))
        log_lik = np.sum((predictions(W_vect, X) * T))
        return ((- log_prior) - log_lik)

    def frac_err(W_vect, X, T):
        return np.mean((np.argmax(T, axis=1) != np.argmax(predictions(W_vect, X), axis=1)))
    return (N, predictions, loss, frac_err)

dataset/ETHPy150Open HIPS/autograd/examples/neural_net.py make_nn_funs/VarMisuse@16/24 `layer_sizes`->`m`