# DLS Course 1 Week 3 logloss incorrect value

I grabbed some test data from compute_cost_test and pasted it into a cell in a notebook and tried what i thought was the simplest version of vectorized logloss, but am getting an incorrect output, so I’m missing something, but don’t see what it is.

The relevant code is as follows:

``````np.random.seed(1)
Y_test = (np.random.randn(1, 5) > 0)
A2 = (np.array([[ 0.5002307 ,  0.49985831,  0.50023963, 0.25, 0.7]]))
m = Y_test.shape[1]

expected_output = 0.5447066599017815
print("expected_output: %f" % expected_output)
actual_output = -np.sum((Y_test*np.log(A2)) + ((1 - Y_test) * (1 - np.log(A2))))/m
print("actual_output: %f" % actual_output)
``````

I’m guessing that I have a simple error in my formula but I can’t seem to see it. I made sure that just using “*” worked the same as np. multiply by doing this

``````print("pos probs np.multiply: " +str(np.multiply(np.log(A2), Y_test)))
print("pos probs raw:" + str(Y_test*np.log(A2)))
``````

The printed output is

``````expected_output: 0.544707
actual_output: -0.944606
pos probs np.multiply: [[-0.69268589 -0.         -0.         -0.         -0.35667494]]
pos probs raw:[[-0.69268589 -0.         -0.         -0.         -0.35667494]]
``````

Any pointers would be greatly appreciated.

regards,
Michael

Turns out to be a pretty silly bug.

The correct answer can be gotten from

``````-np.sum((Y_test*np.log(A2)) + ((1 - Y_test) * np.log(1 - A2)))/m
``````

NOT

``````-np.sum((Y_test*np.log(A2)) + ((1 - Y_test) *(1 - np.log(A2))))/m
``````