Challenge - 5 Problems
Functional API Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output shape of a Functional API model
Consider the following TensorFlow Functional API model. What is the shape of the output tensor?
TensorFlow
import tensorflow as tf inputs = tf.keras.Input(shape=(32,)) x = tf.keras.layers.Dense(64, activation='relu')(inputs) outputs = tf.keras.layers.Dense(10)(x) model = tf.keras.Model(inputs=inputs, outputs=outputs) print(model.output_shape)
Attempts:
2 left
💡 Hint
Remember the first dimension is batch size and is None by default.
✗ Incorrect
The model input shape is (32,), so the output shape is (None, 10) where None is the batch size.
❓ Model Choice
intermediate2:00remaining
Choosing the correct Functional API model for multiple inputs
You want to build a model that takes two inputs: one with shape (10,) and another with shape (5,). Which Functional API model code correctly defines this?
Attempts:
2 left
💡 Hint
Concatenate layer joins inputs along last axis; Add and Multiply require same shape inputs.
✗ Incorrect
Option A correctly concatenates two inputs of different shapes. Add and Multiply layers require inputs of the same shape, so A and C are invalid. Option A ignores input2.
❓ Hyperparameter
advanced2:00remaining
Effect of activation function in Functional API model
In a Functional API model, you replace the activation in a Dense layer from 'relu' to 'linear'. What is the most likely effect on the model's training?
Attempts:
2 left
💡 Hint
Activation functions add non-linearity needed for learning complex data.
✗ Incorrect
Replacing 'relu' with 'linear' removes non-linearity, limiting the model's ability to learn complex patterns, often causing slower or failed training.
🔧 Debug
advanced2:00remaining
Identifying error in Functional API model definition
What error will this Functional API code raise when run?
TensorFlow
import tensorflow as tf inputs = tf.keras.Input(shape=(20,)) x = tf.keras.layers.Dense(10)(inputs) outputs = tf.keras.layers.Dense(5)(inputs) model = tf.keras.Model(inputs=inputs, outputs=outputs) model.compile(optimizer='adam', loss='mse')
Attempts:
2 left
💡 Hint
Outputs can be any tensor derived from inputs, not necessarily last layer.
✗ Incorrect
The code defines outputs directly from inputs, which is valid. Model compiles without error.
🧠 Conceptual
expert3:00remaining
Understanding model summary in Functional API
Given a Functional API model with two input layers merged by Concatenate and followed by two Dense layers, what does the model.summary() show for the total params if the first Dense layer has 8 units and the second has 4 units? Assume input shapes are (3,) and (2,).
Attempts:
2 left
💡 Hint
Calculate params as (input_dim * units) + bias per Dense layer, sum all layers.
✗ Incorrect
Concatenate merges inputs to dimension 5. First Dense(8): 5*8 + 8 = 48 params. Second Dense(4): 8*4 + 4 = 36 params. Total: 84. Option A shows the correct calculation.