Recall & Review
beginner
What is the Sequential model API in TensorFlow?
The Sequential model API is a simple way to build neural networks by stacking layers one after another in order. It is easy to use for beginners and works well for models with a single input and output.
Click to reveal answer
beginner
How do you add layers to a Sequential model?
You add layers by calling the
add() method on the Sequential model object, passing the layer you want to add, like model.add(tf.keras.layers.Dense(10)).Click to reveal answer
beginner
What is the difference between
model.compile() and model.fit() in the Sequential API?model.compile() sets up the learning process by specifying the optimizer, loss function, and metrics. model.fit() trains the model on data for a number of epochs.Click to reveal answer
intermediate
Can the Sequential model API handle models with multiple inputs or outputs?
No, the Sequential model API is designed for simple linear stacks of layers with one input and one output. For multiple inputs or outputs, use the Functional API instead.
Click to reveal answer
beginner
Write a simple Sequential model with one hidden layer of 5 neurons and an output layer of 1 neuron.
import tensorflow as tf
model = tf.keras.Sequential()
model.add(tf.keras.layers.Dense(5, activation='relu', input_shape=(3,)))
model.add(tf.keras.layers.Dense(1))Click to reveal answer
What does the Sequential model API in TensorFlow represent?
✗ Incorrect
The Sequential model API represents a linear stack of layers, where each layer has exactly one input and one output.
Which method is used to add layers to a Sequential model?
✗ Incorrect
The method to add layers in a Sequential model is
add().Which method prepares the Sequential model for training by specifying optimizer and loss?
✗ Incorrect
model.compile() sets the optimizer, loss function, and metrics before training.Can the Sequential API handle models with multiple outputs?
✗ Incorrect
The Sequential API supports only one input and one output. For multiple outputs, use the Functional API.
What is the correct way to specify the input shape in the first layer of a Sequential model?
✗ Incorrect
The input shape should be a tuple, e.g.,
input_shape=(3,) for 3 features.Explain how to build and train a simple neural network using the Sequential model API in TensorFlow.
Think about the steps from model creation to training.
You got /5 concepts.
Describe the limitations of the Sequential model API and when you might need to use the Functional API instead.
Consider model complexity and input/output requirements.
You got /4 concepts.