Challenge - 5 Problems
Multi-Input Multi-Output Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output shape of a multi-input model
Consider a TensorFlow model with two inputs: one of shape (None, 10) and another of shape (None, 5). Both inputs are concatenated and passed through a Dense layer with 8 units. What is the shape of the model's output?
TensorFlow
import tensorflow as tf input1 = tf.keras.Input(shape=(10,)) input2 = tf.keras.Input(shape=(5,)) concat = tf.keras.layers.Concatenate()([input1, input2]) output = tf.keras.layers.Dense(8)(concat) model = tf.keras.Model(inputs=[input1, input2], outputs=output) print(model.output_shape)
Attempts:
2 left
💡 Hint
The Dense layer outputs a tensor with shape (batch_size, units).
✗ Incorrect
The two inputs are concatenated along the last axis, resulting in shape (None, 15). The Dense layer with 8 units transforms this to (None, 8).
❓ Model Choice
intermediate2:00remaining
Choosing the correct multi-output model architecture
You want to build a TensorFlow model that takes one input of shape (20,) and produces two outputs: one for regression (a single continuous value) and one for classification (3 classes). Which model architecture below correctly implements this?
Attempts:
2 left
💡 Hint
Regression output usually has 1 unit without activation; classification output uses softmax for multiple classes.
✗ Incorrect
Option D correctly uses one input, shared layers, and two output heads: one for regression (1 unit, linear) and one for classification (3 units, softmax).
❓ Hyperparameter
advanced2:00remaining
Choosing loss functions for multi-output models
You have a multi-output model with two outputs: a regression output and a 4-class classification output. Which combination of loss functions is appropriate to compile this model?
Attempts:
2 left
💡 Hint
Regression uses mean squared error; multi-class classification uses categorical crossentropy.
✗ Incorrect
Mean squared error (mse) is suitable for regression outputs. Categorical crossentropy is used for multi-class classification with one-hot labels.
🔧 Debug
advanced2:00remaining
Debugging multi-input model input mismatch error
You defined a TensorFlow model with two inputs: input1 shape (None, 8) and input2 shape (None, 4). When training, you get a ValueError about input shapes not matching. Which of the following is the most likely cause?
Attempts:
2 left
💡 Hint
Multi-input models expect inputs as a list or tuple matching the input layers.
✗ Incorrect
Passing a single array instead of a list/tuple of arrays causes shape mismatch errors because the model expects multiple inputs.
🧠 Conceptual
expert2:00remaining
Understanding training metrics in multi-output models
A multi-output model has two outputs: output A (regression) and output B (classification). You compile the model with metrics={'output_A': ['mae'], 'output_B': ['accuracy']}. During training, what will the reported 'accuracy' metric represent?
Attempts:
2 left
💡 Hint
Metrics are reported per output when specified as a dictionary.
✗ Incorrect
The 'accuracy' metric applies only to output B (classification). Output A uses 'mae' metric separately.