Week_3 error:OperatorNotAllowedInGraphError

Hi @pragyan, welcome to Discourse,

Looks like you are conflicting the instruction:

Here again, the delightful @tf.function decorator steps in and saves you time. All you need to do is specify how to compute the cost, and you can do so in one simple step by using:

tf.reduce_mean(tf.keras.losses.binary_crossentropy(y_true = …, y_pred = …, from_logits=True))

with the reference of how it is calculated in TensorFlow:

Just for reference here is how the Binary Cross entropy is calculated in TensorFlow:

mean_reduce(max(logits, 0) - logits * labels + log(1 + exp(-abs(logits))), axis=-1)

For the exercise you should use the former, specifying y_true and y_pred.

Below I add some previous comments on the topic that may be of your interest:

2 Likes