Question regarding the output of tensorflow functions

What’s the exact difference between the final prediction output of the preferred and non-preferred methods? Does the preferred method return a vector of z-values from 1 to N, and the non-preferred one returns a vector of probability a_1 to a_n?

Also, in the week 2 Softmax lab, I try to understand what the function: model.predict(X_train) returns. I know it has four columns because the target value of Y has four classes, but what do the rows stand for, and what factor influences the number of rows?

Thanks for helping!

What shape is your output from .predict(input) ?
What shape is your input ?

1 Like

I am also wondering what you mean by “preferred methods”. Are you talking about the from_logits feature? Can you elaborate more?

Yes, what I mean by the preferred methods is the from_logits feature, the one makes the model more numerically stable.

That’s the problem, apparently, since it’s a tuple, I can’t call its shape.

When "softmax" is specified in the output layer, we set from_logits to False.
When "softmax" is specified in the output layer, the model outputs probabilities as you said.
The number of probabilities is equal to the number of classes.

When "linear" is specified in the output layer, we set from_logits to True.
When "linear" is specified in the output layer, the model outputs logits.
The number of logits is equal to the number of classes.
I think you are referring the logits as z.

Number of samples to predict for.

Cheers,
Raymond

Neither the input nor the output of Keras model.predict() is typically a tuple for the exercises in these classes. See

predict

Args
x Input samples. It could be:

  • A Numpy array (or array-like), or a list of arrays (in case the model has multiple inputs).
  • A TensorFlow tensor, or a list of tensors (in case the model has multiple inputs).
  • A tf.data dataset.
  • A generator or keras.utils.Sequence instance. A more detailed description of unpacking behavior for iterator types (Dataset, generator, Sequence) is given in the Unpacking behavior for iterator-like inputs section of Model.fit.


Returns
Numpy array(s) of predictions.

I had expected you would find that the input shape was something like (m,448,448,3) and the output shape (m,4). The clue, then, being the common first dimension which @rmwkwok points out is the number of inputs or samples.