TensorFlow Introduction. Exercise 6 - compute_total_loss

In calculating y_pred in tf.keras.metrics.categorical_crossentropy(), I used “new_train” as X input. But I keep getting error message like this:
“ValueError: Attempt to convert a value (<MapDataset shapes: (12288,), types: tf.float32>) with an unsupported type (<class ‘tensorflow.python.data.ops.dataset_ops.MapDataset’>) to a Tensor.”
where did I go wrong?

Please keep a few things in mind:

  1. The loss function you’ve used is from the metrics module. Do read the markdown that mentions the correct function to use from the losses module.
  2. Pay attention to the shape of input variables and the shape of inputs expected by the loss function.
  3. Loss is computed per mini batch, and so using the complete training set made of X and y is incorrect. As an additional hint, look at the variables in the for construct for mini batches.

Here’s a post with a checklist of the most common errors on this section.

Note that you don’t have to reference any global variables: the inputs to the cross entropy function are derived from the input parameters that are passed in the call to compute_total_loss.

Oh I see! it’s such a dumb question. It’s working now. Thank you for prompt response.