C3W3_Assignment Exercise 4 Invalid Confusion Matrix

I am getting an invalid confusion matrix in Exercise 4. I am not sure where I am going wrong

can you post screenshot of your invalid matrix value without posting any codes that you wrote.

you seem to have edited the codes. don’t add your own codes.

You were suppose to only write codes between ###START AND END CODE HERE### for the instructions already given.

you initiated the below part of code


accuracy = 0

for j in range(batch_size):
    d = math.reduce_sum(v1[j]*v2[j])
    res = d > threshold 
    accuracy += tf.cast(y_test[j] == res, tf.float64)
    if(y_test[j] == res):
        y_pred.append(1)
    else:
        y_pred.append(0)
        
    
accuracy = accuracy / batch_size

then at the end

This is not the way codes works. Get a fresh copy, then implement the steps as per each instructions given.

The below thread should help you resolve your issue

Regards
DP

1 Like

@Mahnoor_Malik

the correction you did is still not correct for cosine similarity and accuracy codes

for accuracy codes correction refer the previous comment link in the same thread.

For cosine similarity codes correction, refer the below thread comment