Open lilinilili opened 3 years ago
Sorry for my very late response! by writing this line
loss=tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True)
tensorflow will add the softmax itself. Because we are using cross entropy loss and our output values must be between 0 and 1 (look at the cross-entropy loss).
After compiling and training the model we aim to see the output of the network in terms of probability. The last layer of network is Dense; it gives some numbers without any limitation. So by adding softmax here for prediction we are actually just scaling values from (-inf,+inf) to (0,1)!
sir, i wondering why add softmax layer after compile model and was there influence to add this layer when building the model?