Issues with Programming Assignment C1_W1

The notebook compiles and runs fine when I manually run it. Giving the correct output and the test passes. However, the autograder keeps failing with the following error:

Cell #UNQ_C3. Can’t compile the student’s code. Error: NotImplementedError(‘Cannot convert a symbolic Tensor (Const:0) to a numpy array.’,)

Here is the relevant code:

{moderator edit - solution code removed}

Any help would be much appreciated.

1 Like

It’s been a while since I looked at that assignment, but I implemented that function using only numpy functions. Why do you need Keras there?


Hello @mikelo,

Please delete your codes, it is against community guidelines to share grader codes.

You do not need to compute class freq separately for true labels rather use pos weights and neg_weights directly into your loss equation.

Did you notice an equation given before that cell(sharing here with you)

Notice for the final weight loss one is suppose to use pos_weights and neg_weights.
Also while you are implementation K.mean is correction but you do need to use keras mean separately for pos_weights and neg_Weights.
Also your operator placement(compare with the image shared) before Keras mean is incorrect here. The operator placement is for the sum of the pos weight and neg weights together and not for keras mean.

Write the equation in tuple for sum of these weightings the positive and negative labels within each class with the operator placed as per the image shared here and that equation needs to be implemented with keras mean.

Let me know if your issue is resolved.


Thank you for responding. The assignment specificially asked to use Keras and to leverage mean. Otherwise, I would have used numpy. I will see if numpy solves it

1 Like

Thank you Deepti.

It seems that using my own weights from the previous part of the assignment vs those passed in caused that error.

I have no idea why as they had the same values and were both of type numpy.ndarray.

However, that did the trick.

Thank you!

Hello @mikelo,

Kindly delete the codes.

Your error clearly mentions the issue was with the implementation and not with numpy.ndarray as some part of your codes were perfectly right.


I would. However, the forum won’t let me edit my original post.

No worries, I edited the post.