C1W1: UNQ_C3: Not full marks due to k.means error

The autograder is giving me the following error:

Function "(K\.mean)|(tf\.keras\.backend\.mean)" not found in Code Cell UNQ_C3.
Function "(K\.log)|(tf\.keras\.backend\.log)" not found in Code Cell UNQ_C3.
Code Cell UNQ_C1: Function 'check_for_leakage' is correct.
Code Cell UNQ_C2: Function 'compute_class_freqs' is correct.
Code Cell UNQ_C3: Function 'get_weighted_loss' is correct. 
If you see many functions being marked as incorrect, try to trace back your steps & identify if there is an incorrect function that is being used in other steps.
This dependency may be the cause of the errors.

but I only got a score of 67%.
This output tells me that I actually got the functions correct, is that right?
The only error i have is related to using keras.backend.mean/log

I did in fact use these in my solution:

from keras.backend import mean as keras_mean
from keras.backend import log as keras_log
...
loss = -1 * keras_mean( ... )
...

The unit tests all passed.

Thanks!

My guess is because you used the importas and provided a nonstandard name. Did you try using a fully qualified path name in the code instead? Eg tf.keras.backend.mean instead of keras_mean

Yes it works with the (fully) qualified path:

from keras import backend as K
loss = -1 * K.mean( ... ) ... K.log()

I get that its an autograding algo, so has limitations, but was surprising and confusing to get docked so many narks for this when it is not an error.
Anyway thanks, resubmitted and got the full marks. Will keep out for similar issues in future assignments.

2 Likes

I just wrote a reply to a similar issue here: UNQ_C2 error on autograder eventhough all function are correct - #3 by ai_curious

Tl;dr …. Python always allows more than one way to express your intent, but the grader, not so much.