Breast Cancer Prediction Gradient problem

Hi,
In the assignment, I have defined this apply_gradient function.

    With tf.GradientTape() as tape:
    ### START CODE HERE ###
        logits = model(x)
        loss_value = loss_object(y_true=y, y_pred=logits)

But in it is made an error.

---> 15         logits = model(x)
     16         loss_value = loss_object(y_true=y, y_pred=logits)
     17 

TypeError: __call__() missing 1 required positional argument: 'y_pred'

Hmm, @MohammadReza_Lahmi,
That error suggests the code is expecting a second argument, y_pred when you’re calling model(x) - as if model is somehow defined to be a loss object.

Some things I’d suggest looking at:

  1. Print out the type of model. Is it a loss class, like BInaryCrossEntropy?
  2. Look in the lines above and see if model is getting assigned to a loss object somewhere. Maybe a typo or something left over from an experiment?
2 Likes

What @Wendy suggest are a must to check but I also would point out that it is possible the model(x) is not loaded properly and its not producing the logits.

Check whether the test_model file is part of the lab files at file->open and is loading properly. Also make sure that you are running all cells above this cell!

1 Like