C3W3 - Ex4 - classify - CM correct, accuracy far to low

Hello everyone,

need to ask for help again. Couldn’t get the accuracy value correct within C3W3 assignment, ex 4 - classify.

After predicting the test gen data the result is split up the same way as in the tripletloss function a couple of cells above resulting in v1 and v2 shapes of (10240,128). The “d” is calculated with the reduce_sum of the product of the two vectors with axis=1. Shape collapses down to (10240,). After that i’ve made an compare of d>thres within the tf.cast to get y_pred. The accuracy is then calculated via a reduce_mean on y_pred like mentioned in this post

No axis argument should be necessary because it is only (10240,).

Finally confusion matrix is calculated with y_test and y_pred. The values of the CM are as they shoud be, accuracy is only at 0.396…

Can someone give me a hint what i have missed? All unit tests as well as the autograder for the earlier ex are passed.

Many thanks in advance!

hi @RoWe84

Kindly share a screenshot of your output with expected output. please make sure not to post any codes here.

Regards
DP

I am having trouble defining y_pred = tf.cast(d>threshold, tf.float64), i am not sure what is wrong. Can someone please help me with this

Hi @mackaseck,

You can create a new post for more visibility on this issue!

In the meantime, make sure that both d and threshold are properly defined as tensors with compatible shapes for the comparison. Also, if you’re encountering a specific error, feel free to share the error message.

2 Likes

Thanks Alireza, ill create a new post for it

1 Like