Example #1
0
def compute_acc(X, Y, W):
    y_hat = sr.compute_a(sr.compute_z(X, W, 0))
    y_hat_indicies = np.argmax(y_hat, axis=1)
    y_indicies = np.argmax(Y, axis=1)
    error = np.array([y_indicies == y_hat_indicies])
    acc = error.sum() / X.shape[0]
    return acc
Example #2
0
def compute_a2(z2):
    '''
        Compute the softmax activations a2 from the linear logits z2 in the second layer. 
        Input:
            z2: linear logits in the second layer, a float numpy vector of shape c by 1. 
                Here c is the number of classes. 
        Output:
            a2: the non-linear activations in the 2nd layer, a float numpy vector of shape c by 1. 
        Hint: you could solve this problem using 1 line of code.
    '''
    a2 = sr.compute_a(z2)
    return a2