Challenge - 5 Problems
Softmax Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate1:30remaining
Output shape of a softmax layer
What is the shape of the output tensor after applying a softmax layer with 10 units to an input batch of shape (32, 100)?
TensorFlow
import tensorflow as tf inputs = tf.random.uniform((32, 100)) softmax_layer = tf.keras.layers.Dense(10, activation='softmax') outputs = softmax_layer(inputs) output_shape = outputs.shape print(output_shape)
Attempts:
2 left
💡 Hint
The softmax layer outputs one probability distribution per input example.
✗ Incorrect
The Dense layer with 10 units outputs a tensor with shape (batch_size, 10). Since the input batch size is 32, the output shape is (32, 10).
❓ Model Choice
intermediate1:30remaining
Choosing the correct output layer for multi-class classification
You want to build a neural network to classify images into 5 categories. Which output layer configuration is correct?
Attempts:
2 left
💡 Hint
Softmax is used for multi-class classification with mutually exclusive classes.
✗ Incorrect
For multi-class classification with 5 classes, the output layer should have 5 units with softmax activation to output probabilities summing to 1.
❓ Hyperparameter
advanced2:00remaining
Effect of temperature parameter on softmax output
In a softmax function, what is the effect of increasing the temperature parameter T > 1 on the output probabilities?
Attempts:
2 left
💡 Hint
Temperature controls the sharpness of the softmax distribution.
✗ Incorrect
Increasing temperature smooths the output distribution, making probabilities closer to uniform and less confident.
❓ Metrics
advanced1:30remaining
Correct loss function for softmax output layer
Which loss function should you use when training a model with a softmax output layer for multi-class classification?
Attempts:
2 left
💡 Hint
The loss function must match the output activation and label format.
✗ Incorrect
SparseCategoricalCrossentropy is used with softmax outputs and integer labels for multi-class classification.
🔧 Debug
expert2:00remaining
Identifying the error in softmax output layer usage
What error will occur when compiling this model?
import tensorflow as tf
model = tf.keras.Sequential([
tf.keras.layers.Dense(10),
tf.keras.layers.Softmax()
])
model.compile(optimizer='adam', loss='sparse_categorical_crossentropy')
TensorFlow
import tensorflow as tf model = tf.keras.Sequential([ tf.keras.layers.Dense(10), tf.keras.layers.Softmax() ]) model.compile(optimizer='adam', loss='sparse_categorical_crossentropy')
Attempts:
2 left
💡 Hint
Softmax can be a separate layer; loss expects probabilities by default.
✗ Incorrect
The model outputs probabilities because of the Softmax layer. The loss SparseCategoricalCrossentropy expects probabilities by default (from_logits=False), so no error occurs.