Deep Learning with Keras
- 83Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
What is Keras, as described in the course?
What is Keras, as described in the course?
83 questions
- 1
What is Keras, as described in the course?
- A
A Python neural network API integrated with TensorFlow
- B
A hardware library used only to configure GPUs
- C
A database system for storing trained neural networks
- D
A data-labeling tool that runs independently of Python
Correct answer
AA Python neural network API integrated with TensorFlow
Explanation
Keras is a neural network API written in Python and integrated with TensorFlow.
- A
- 2
What design goal is highlighted as a key strength of Keras?
- A
Restricting users to a single fixed neural network architecture
- B
Making model training possible only on specialized hardware
- C
Enabling fast experimentation from an idea to an implementation in few steps
- D
Requiring users to write every network operation from low-level primitives
Correct answer
CEnabling fast experimentation from an idea to an implementation in few steps
Explanation
Keras was developed with a focus on fast user experimentation, helping users move from ideas to implementations in few steps.
- A
- 3
Why does the course recommend learning more than one neural network API?
- A
Every API is required to train a single neural network successfully
- B
Understanding one API makes the concepts and syntactic differences in others easier to learn and compare
- C
Using multiple APIs eliminates the need to understand deep learning concepts
- D
Different APIs always produce identical implementations for every problem
Correct answer
BUnderstanding one API makes the concepts and syntactic differences in others easier to learn and compare
Explanation
Once the underlying concepts are understood, differences in syntax and implementation across APIs are easier to pick up. Familiarity with multiple APIs also supports comparison and discussion of their suitability for different problems.
- A
- 4
How did Keras historically relate to lower-level neural network libraries?
- A
It could be configured to run on TensorFlow, Theano, or CNTK
- B
It required all three libraries to run together
- C
It was a component of CNTK that could run only on Theano
- D
It replaced TensorFlow, Theano, and CNTK as a hardware driver
Correct answer
AIt could be configured to run on TensorFlow, Theano, or CNTK
Explanation
Historically, Keras was a high-level API that could run on one of three lower-level back ends: TensorFlow, Theano, or CNTK.
- A
- 5
How is Keras described in the course's TensorFlow context?
- A
It is a GPU-only package unrelated to TensorFlow
- B
It is a separate library that must always be paired with CNTK
- C
It is a low-level replacement for TensorFlow's computation engine
- D
It is integrated with TensorFlow rather than being selected as a separate back-end library
Correct answer
DIt is integrated with TensorFlow rather than being selected as a separate back-end library
Explanation
The course explains that Keras became fully integrated with TensorFlow and is no longer a separate library chosen to run against one of several back ends.
- A
- 6
What installation command is given for installing TensorFlow with Keras?
- A
Download CNTK and then install Keras separately
- B
Run
pip install tensorflowfrom the command line - C
Run
pip install keras-gpufrom a notebook cell - D
Install NumPy and Keras without installing TensorFlow
Correct answer
BRun
pip install tensorflowfrom the command lineExplanation
Because Keras is packaged with TensorFlow, the course gives
pip install tensorflowas the installation command. - A
- 7
What programming experience is described as sufficient for the coding prerequisites?
- A
Basic programming skills and some Python experience
- B
Professional experience maintaining TensorFlow itself
- C
Prior experience building state-of-the-art models from scratch
- D
Advanced experience writing custom GPU kernels
Correct answer
ABasic programming skills and some Python experience
Explanation
The course states that basic programming skills and some Python experience are sufficient coding prerequisites.
- A
- 8
Is a GPU necessary to follow the course examples?
- A
Yes; TensorFlow cannot train or evaluate models on a CPU
- B
No; a GPU is required only for numerical datasets
- C
Yes; only image-processing code can run on a GPU
- D
No; the code can run on a CPU, though a GPU may offer speed advantages
Correct answer
DNo; the code can run on a CPU, though a GPU may offer speed advantages
Explanation
A GPU is not required. The course says its code will run on a CPU, while a GPU can be set up later to observe possible efficiency and speed improvements.
- A
- 9
In supervised learning, what does the term sample refer to?
- A
An individual data point in a dataset
- B
A group of model weights updated in one training step
- C
The predicted class with the highest probability
- D
A measure of the model's validation accuracy
Correct answer
AAn individual data point in a dataset
Explanation
A dataset consists of data points, and each data point is referred to as a sample. Samples may also be called inputs or input data.
- A
- 10
What are labels in a supervised learning dataset?
- A
The input features after normalization
- B
The set of samples reserved for validation
- C
The model's hidden-layer activations
- D
The target values corresponding to the samples
Correct answer
DThe target values corresponding to the samples
Explanation
Labels are the targets corresponding to samples. The course also refers to them as targets or target data.
- A
- 11
For a sentiment task using headlines, which pair illustrates samples and labels?
- A
Sentiment categories are samples, and headlines are the labels
- B
Headlines are labels, and neural network layers are the samples
- C
Headlines are samples, and positive or negative sentiment is the label
- D
Model predictions are samples, and training epochs are the labels
Correct answer
CHeadlines are samples, and positive or negative sentiment is the label
Explanation
Each headline is a sample, and its corresponding positive or negative sentiment is the label.
- A
- 12
Why should the task be understood before choosing how to format a dataset?
- A
The task sets the number of GPUs available
- B
The task determines which optimizer must be installed
- C
The task determines the format needed to pass data to the model
- D
The task makes sample labels unnecessary
Correct answer
CThe task determines the format needed to pass data to the model
Explanation
Understanding the task helps determine the data format required for the model that will receive the data.
- A
- 13
Which pair of arguments does the Keras
fitfunction use for input samples and their targets?- A
xfor epochs andyfor batch size - B
xfor input samples andyfor target data - C
xfor validation metrics andyfor model weights - D
xfor target data andyfor optimizer settings
Correct answer
Bxfor input samples andyfor target dataExplanation
The
fitfunction expectsxas input data or samples andyas the corresponding labels or target data. - A
- 14
Which set contains formats the course identifies as acceptable for
xinput data?- A
Only a Python list, CSV file, or image filename
- B
Only a TensorFlow tensor or a trained model
- C
A confusion matrix, optimizer, or model summary
- D
A NumPy array, TensorFlow tensor, dictionary-like mapping,
tf.data.Dataset, or Keras generator
Correct answer
DA NumPy array, TensorFlow tensor, dictionary-like mapping,
tf.data.Dataset, or Keras generatorExplanation
The course lists NumPy arrays, TensorFlow tensors, mappings,
tf.data.Datasetobjects, and Keras generators as accepted input formats. - A
- 15
What format relationship must hold between the
xandyarguments tofit?- A
They must use matching data formats
- B
xmust be a NumPy array andymust be a TensorFlow tensor - C
They must have different formats so the model can distinguish them
- D
xmust contain labels andymust contain samples
Correct answer
AThey must use matching data formats
Explanation
The course says that
xandymust have the same format; for example, both can be NumPy arrays. - A
- 16
In the imagined clinical trial, what did a label of one represent?
- A
The patient was assigned to the validation set
- B
The patient experienced no side effects
- C
The patient experienced side effects
- D
The patient was younger than 65
Correct answer
CThe patient experienced side effects
Explanation
In the generated dataset, label one represented experiencing side effects, while label zero represented no side effects.
- A
- 17
What pattern did the imagined clinical-trial data represent?
- A
About 95% of younger patients had side effects, while about 95% of older patients did not
- B
Side effects were assigned independently of patient age in the generated data
- C
Patients of all ages had side effects at exactly the same rate
- D
About 95% of older patients had side effects, while about 95% of younger patients did not
Correct answer
DAbout 95% of older patients had side effects, while about 95% of younger patients did not
Explanation
The example data represented approximately 95% of patients aged 65 or older as having side effects and approximately 95% of those under 65 as having none.
- A
- 18
Why were the generated samples and labels shuffled before training?
- A
To change the labels from zero and one into class names
- B
To remove ordering introduced during data generation while keeping sample-label correspondence
- C
To force all samples into the validation set
- D
To make the sample values fall between zero and one
Correct answer
BTo remove ordering introduced during data generation while keeping sample-label correspondence
Explanation
The samples and corresponding labels were shuffled together to remove imposed order from the generation process without breaking their correspondence.
- A
- 19
Why was a min-max scaler used on the age samples?
- A
To rescale the values from their original range of 13–100 to a range of 0–1
- B
To divide the samples into training and test sets
- C
To change the number of dimensions in the neural network
- D
To convert the labels from integers to text
Correct answer
ATo rescale the values from their original range of 13–100 to a range of 0–1
Explanation
The min-max scaler transformed the age values from their original scale of 13 to 100 to a scale between zero and one.
- A
- 20
Why was the one-dimensional age data reshaped before applying the scaler's transformation?
- A
The model required all ages to be converted into images
- B
The transformation function did not accept one-dimensional data in its default form
- C
The transformation function only accepted string labels
- D
Reshaping was necessary to shuffle labels independently
Correct answer
BThe transformation function did not accept one-dimensional data in its default form
Explanation
The course reshaped the one-dimensional samples because the scaler's
fit_transformfunction did not accept one-dimensional data by default. - A
- 21
What is a Keras Sequential model?
- A
A linear stack of layers
- B
A data iterator that sorts samples by label
- C
A collection of independent models that vote on predictions
- D
A training procedure that updates only output-layer weights
Correct answer
AA linear stack of layers
Explanation
The Sequential model is described as a linear stack of layers.
- A
- 22
In the Sequential model example, how is the input layer established?
- A
The input data implicitly creates it, and the first layer's
input_shapespecifies the expected input shape - B
It is always a dense layer that must be listed separately before all other layers
- C
It is supplied as the final layer after the output layer
- D
It is created by the optimizer when training begins
Correct answer
AThe input data implicitly creates it, and the first layer's
input_shapespecifies the expected input shapeExplanation
The example does not explicitly define an input layer. The input data creates it, while the first hidden layer's
input_shapetells the model what input shape to expect. - A
- 23
What does the
unitssetting in a dense layer specify?- A
The number of classes in the validation set
- B
The number of neurons or nodes in that layer
- C
The number of samples in each batch
- D
The number of training epochs
Correct answer
BThe number of neurons or nodes in that layer
Explanation
The course uses units to refer to the nodes or neurons in a dense layer.
- A
- 24
Why did the example output layer have two units?
- A
The model had two hidden layers
- B
The task had two possible classes: side effects or no side effects
- C
The input data contained two age values per patient
- D
The training set was split into two batches
Correct answer
BThe task had two possible classes: side effects or no side effects
Explanation
The output layer had two units because the example classified patients into two classes: experiencing side effects or not experiencing them.
- A
- 25
What does the softmax activation on a multiclass output layer provide?
- A
A shuffled ordering of the training samples
- B
The model's optimizer state
- C
Probabilities for the possible output classes
- D
A normalized range of input ages only
Correct answer
CProbabilities for the possible output classes
Explanation
The output softmax provides probabilities for each output class, allowing the model's class predictions to be compared.
- A
- 26
What is the purpose of calling
compilebefore training?- A
It prepares the model for training by specifying choices such as the optimizer, loss, and metrics
- B
It saves the model architecture to a JSON string
- C
It creates a separate test set from the validation data
- D
It converts the training data into image files
Correct answer
AIt prepares the model for training by specifying choices such as the optimizer, loss, and metrics
Explanation
Compiling prepares the model for training and sets items such as the optimizer, loss function, and metrics.
- A
- 27
In the numerical example, what did a batch size of 10 mean?
- A
Ten classes were predicted for each sample
- B
The model trained for ten epochs
- C
Ten percent of the samples were reserved for validation
- D
Ten samples were processed together in one batch
Correct answer
DTen samples were processed together in one batch
Explanation
Batch size specifies how many samples are included in a batch processed by the network at one time.
- A
- 28
What does training for 30 epochs mean?
- A
The model uses 30 output classes
- B
The model processes 30 samples in total
- C
The model processes the entire dataset 30 times
- D
The model reserves 30% of its data for testing
Correct answer
CThe model processes the entire dataset 30 times
Explanation
An epoch is a pass through all the data, so 30 epochs mean training on the entire dataset 30 times.
- A
- 29
What does the
shuffleoption infitdo during training?- A
It randomly changes the model's output labels
- B
It shuffles the layers in the network after every epoch
- C
It shuffles the training data before it is passed through the model
- D
It divides each batch into training and test samples
Correct answer
CIt shuffles the training data before it is passed through the model
Explanation
The course explains that the training data is shuffled by default during
fit, helping prevent the model from learning an imposed data order. - A
- 30
What is the role of the
verbosesetting infit?- A
It controls how many classes the model predicts
- B
It selects the data format used for
xandy - C
It determines whether model weights can be saved
- D
It controls how much output the training function displays
Correct answer
DIt controls how much output the training function displays
Explanation
The
verbosesetting controls the amount of output displayed during training; the course notes that a value of two gives the most verbose output. - A
- 31
What is the purpose of a validation set during model training?
- A
To add the validation examples to every training batch
- B
To replace the labels in the training set
- C
To evaluate how the model predicts on data that it does not train on
- D
To update the model's weights without using training data
Correct answer
CTo evaluate how the model predicts on data that it does not train on
Explanation
The validation set lets users assess performance on data held out from training and get an indication of how well the model generalizes.
- A
- 32
When validation data is used during each epoch, what happens to it?
- A
It is merged into the training data and shuffled with it
- B
It is used only to determine the number of output classes
- C
The model uses it to update its weights before training begins
- D
The model predicts on it after training on that epoch's training data
Correct answer
DThe model predicts on it after training on that epoch's training data
Explanation
After training on the training data in an epoch, the model can predict on the validation data to report validation metrics.
- A
- 33
What is true about the validation set's role in training?
- A
It is used to replace the training set during alternate epochs
- B
It is used only after the model has been deployed
- C
It is used to assess performance but is not used to train the model's weights
- D
It is used to train the model after every training batch
Correct answer
CIt is used to assess performance but is not used to train the model's weights
Explanation
The validation set is held out of training. It allows evaluation on unseen examples but is not used to train the model.
- A
- 34
What pattern can indicate overfitting when comparing training and validation results?
- A
Strong validation performance combined with weaker training performance
- B
Similar training and validation performance at a low accuracy level
- C
Strong training performance combined with notably weaker validation performance
- D
Identical training and validation losses after every batch
Correct answer
CStrong training performance combined with notably weaker validation performance
Explanation
Overfitting is indicated when the model performs very well on the training set but less well on the held-out validation set, suggesting poor generalization.
- A
- 35
What does
validation_splitdo when passed tofit?- A
It specifies how many output classes the model has
- B
It combines the validation set with the test set
- C
It shuffles all samples before any data is divided
- D
It sets aside a fraction of the training data for validation
Correct answer
DIt sets aside a fraction of the training data for validation
Explanation
The
validation_splitparameter tells Keras to set aside a fraction of the provided training data as validation data. - A
- 36
When Keras creates a validation set using
validation_split, when does the split occur relative to training-data shuffling?- A
The split occurs only after each training epoch
- B
The split occurs before the training data is shuffled
- C
The split occurs after the model has made predictions
- D
The split occurs after the training data is converted to labels
Correct answer
BThe split occurs before the training data is shuffled
Explanation
The course warns that the validation split occurs before the training set is shuffled by
fit, so the held-out portion may reflect the original ordering. - A
- 37
Why is it useful to shuffle data before using
validation_split?- A
It guarantees that the validation accuracy will match training accuracy
- B
It converts the validation examples to the same labels as the training set
- C
It helps prevent the held-out portion from containing only one ordered subgroup
- D
It ensures the validation set is included in model weight updates
Correct answer
CIt helps prevent the held-out portion from containing only one ordered subgroup
Explanation
Because Keras takes the validation portion before shuffling, pre-shuffling helps avoid selecting a contiguous, potentially unrepresentative group of samples.
- A
- 38
What does inference mean in the course's model workflow?
- A
Using what a trained model learned to make predictions on data it has not seen before
- B
Calculating the shape of the model's input layer
- C
Splitting the original dataset into training and validation sets
- D
Updating model weights using all available labels
Correct answer
AUsing what a trained model learned to make predictions on data it has not seen before
Explanation
Inference is the process of using a trained model's learned knowledge to make predictions on new data.
- A
- 39
What is the typical role of a test set in the workflow described?
- A
It is used to update model weights during every epoch
- B
It is held out and used for inference after training and validation
- C
It provides the input shape for the first hidden layer
- D
It replaces the validation set during model compilation
Correct answer
BIt is held out and used for inference after training and validation
Explanation
The course describes using a held-out test set for inference after training and validation, as an additional check before deployment.
- A
- 40
Why are test labels not passed to a model when using it for inference?
- A
Test labels are automatically converted into model weights
- B
Passing labels would make the model unable to process input samples
- C
Labels are not supported by any supervised learning model
- D
Inference uses the model to produce predictions from inputs; labels, when available, are used separately to assess results
Correct answer
DInference uses the model to produce predictions from inputs; labels, when available, are used separately to assess results
Explanation
During inference, the model receives inputs to predict on, not the correct labels. If the labels are available, they can later be compared with predictions to evaluate performance.
- A
- 41
What information does a confusion matrix provide when true test labels are available?
- A
The order in which training batches were processed
- B
A comparison of predicted classes with true classes
- C
The pixel values used by the image preprocessor
- D
The optimizer state saved during training
Correct answer
BA comparison of predicted classes with true classes
Explanation
A confusion matrix compares predicted labels with true labels, making it possible to inspect correct and incorrect predictions by class.
- A
- 42
In the course's confusion-matrix convention, where are correct predictions found?
- A
Only in the final column of the matrix
- B
Only in the first row of the matrix
- C
Along the diagonal from the top right to the bottom left
- D
Along the diagonal from the top left to the bottom right
Correct answer
DAlong the diagonal from the top left to the bottom right
Explanation
The course's plotted confusion matrices place correct predictions along the diagonal running from the top left to the bottom right.
- A
- 43
In the clinical-trial example, what accuracy did the confusion matrix indicate on the test set?
- A
About 96%, with 396 correct predictions out of 400
- B
About 70%, with 300 correct predictions out of 420
- C
About 50%, with 210 correct predictions out of 420
- D
About 94%, with 396 correct predictions out of 420
Correct answer
DAbout 94%, with 396 correct predictions out of 420
Explanation
The example reported 396 correct predictions out of 420 total, which is approximately 94% accuracy.
- A
- 44
What does the complete Keras model-saving option preserve, according to the course?
- A
Only the architecture and input shape
- B
Architecture, weights, training configuration, and optimizer state
- C
Only the optimizer and validation metrics
- D
Only the weights and class labels
Correct answer
BArchitecture, weights, training configuration, and optimizer state
Explanation
Calling
savepreserves the model architecture and weights, along with training configuration and optimizer state. - A
- 45
Why can saving the optimizer state be useful when training is interrupted?
- A
It converts the optimizer into a validation dataset
- B
It can allow training to resume from the saved state after the model is loaded
- C
It automatically creates new training labels
- D
It prevents the model architecture from being changed
Correct answer
BIt can allow training to resume from the saved state after the model is loaded
Explanation
Because the optimizer state is saved, the course explains that training can be resumed from where it left off after loading the model.
- A
- 46
What does saving a model with
to_jsonpreserve?- A
The model's test predictions and confusion matrix
- B
The model architecture, but not its weights or training configuration
- C
The weights and optimizer state, but not the architecture
- D
The training data and its labels
Correct answer
BThe model architecture, but not its weights or training configuration
Explanation
The
to_jsonmethod saves the architecture as a JSON string. Weights and training configuration are not included. - A
- 47
What must be done before a model reconstructed from a JSON architecture can be trained?
- A
Its layers must be converted into image generators
- B
Its predictions must be placed into a confusion matrix
- C
Its original test set must be added to the JSON string
- D
Its weights must be trained and its training configuration, such as the optimizer and loss, must be set
Correct answer
DIts weights must be trained and its training configuration, such as the optimizer and loss, must be set
Explanation
Loading only the architecture does not restore trained weights or training configuration, so the model needs to be compiled and trained as required.
- A
- 48
What does saving weights alone require when loading them later?
- A
A JSON string containing the optimizer must be loaded first
- B
A model with a matching architecture must be created before loading the weights
- C
The original training samples must be converted to a confusion matrix
- D
The weights must be loaded into any model regardless of its layer structure
Correct answer
BA model with a matching architecture must be created before loading the weights
Explanation
The weights-only option does not save the model architecture, so a compatible model must be created before those weights are loaded.
- A
- 49
Why must a weights-only destination model have a compatible architecture?
- A
Its optimizer must have the same name as the original model
- B
It must have used the same validation split percentage
- C
Its output labels must be stored in the same file name
- D
Its layers and weight shapes need to match the saved weights
Correct answer
DIts layers and weight shapes need to match the saved weights
Explanation
Weights need to map to the corresponding layers, so the destination model must have a compatible architecture and matching weight shapes.
- A
- 50
Which alternate architecture-serialization format is mentioned alongside JSON?
- A
YAML
- B
HTML
- C
PNG
- D
CSV
Correct answer
AYAML
Explanation
The course notes that a similar architecture-saving and loading process can be done using YAML instead of JSON.
- A
- 51
Why were images in the cats-versus-dogs task organized into directories by class?
- A
Directory names specify the image's RGB pixel values
- B
The model can only process images when each is stored in a separate model file
- C
Directory structure and class names let the image generator find samples and associate them with labels
- D
The directory names determine the optimizer used for each image
Correct answer
CDirectory structure and class names let the image generator find samples and associate them with labels
Explanation
The image workflow uses directories for classes such as cat and dog, which lets the generator locate images and associate them with the corresponding classes.
- A
- 52
What image dimensions were specified for the cats-and-dogs image batches?
- A
32×32 pixels
- B
224×224 pixels
- C
100×100 pixels
- D
500×500 pixels
Correct answer
B224×224 pixels
Explanation
The image generators resized the images to a target size of 224×224.
- A
- 53
What does
flow_from_directoryprovide in the described image-processing workflow?- A
A list of optimized model weights
- B
A saved model architecture in JSON format
- C
Batches of images and their labels from a directory structure
- D
A complete confusion matrix from model predictions
Correct answer
CBatches of images and their labels from a directory structure
Explanation
The course uses
ImageDataGenerator.flow_from_directoryto create directory iterators that produce batches of images and labels. - A
- 54
Why did the test image generator use
shuffle=False?- A
To preserve the mapping between test samples and their labels for evaluation
- B
To prevent the training data from being shuffled during fitting
- C
To make all test images belong to the same class
- D
To disable resizing and preprocessing for test images
Correct answer
ATo preserve the mapping between test samples and their labels for evaluation
Explanation
Keeping test samples unshuffled makes it possible to align predictions with the corresponding unshuffled test labels when creating a confusion matrix.
- A
- 55
Why did the course apply the same relevant preprocessing to test images as to training images?
- A
Only test images need to be converted to labels
- B
Preprocessing determines the order of the model's layers
- C
The model should receive test data in a format consistent with the data used for training
- D
Test images must have different preprocessing to avoid matching training samples
Correct answer
CThe model should receive test data in a format consistent with the data used for training
Explanation
The course emphasizes preparing the test set in the same format as the training data so the model receives consistent inputs.
- A
- 56
What is the purpose of the input-shape setting in the first convolutional layer of the example CNN?
- A
It determines how many images are in a training batch
- B
It tells the model the expected image height, width, and number of color channels
- C
It specifies how many classes are used in the validation set
- D
It sets the size of the model's optimizer state
Correct answer
BIt tells the model the expected image height, width, and number of color channels
Explanation
The example specifies an input shape of 224×224 with three color channels, informing the model about the expected input images.
- A
- 57
In the example CNN, what does
padding='same'do?- A
It makes every class contain the same number of images
- B
It ensures all layers have the same number of filters
- C
It adds padding so convolution operations do not reduce the image dimensions
- D
It assigns the same probability to each output class
Correct answer
CIt adds padding so convolution operations do not reduce the image dimensions
Explanation
The course explains that same padding uses zero padding around the images so their dimensionality is not reduced by the convolution operations.
- A
- 58
What is the effect of the example's 2×2 max-pooling operation with stride 2?
- A
It doubles the number of color channels
- B
It reduces the image dimensions by half
- C
It increases the image dimensions by a factor of two
- D
It converts each image into a label vector
Correct answer
BIt reduces the image dimensions by half
Explanation
The course describes this max-pooling setup as cutting the image dimensions in half.
- A
- 59
Why is a convolutional network's feature map flattened before passing it to the dense output layer?
- A
To create a separate validation dataset
- B
To convert it into a one-dimensional representation for the dense layer
- C
To change the image labels into RGB values
- D
To restore image dimensions removed by max pooling
Correct answer
BTo convert it into a one-dimensional representation for the dense layer
Explanation
The example flattens the convolutional output into a one-dimensional tensor before passing it to a dense output layer.
- A
- 60
Why can a two-class CNN use categorical cross-entropy with two softmax outputs, or binary cross-entropy with one sigmoid output?
- A
Both setups remove the need for labels during training
- B
Both setups require the model to have two input layers
- C
Both setups can represent the two-class prediction task and yield equivalent results in the described case
- D
The two setups are identical only when the dataset has no validation set
Correct answer
CBoth setups can represent the two-class prediction task and yield equivalent results in the described case
Explanation
The course states that categorical cross-entropy with two softmax outputs and binary cross-entropy with one sigmoid output are equivalent approaches for the two-class case.
- A
- 61
What did the scratch-built CNN's training and validation results suggest?
- A
It could not process image data because it used a Sequential model
- B
It had no output layer and therefore produced no predictions
- C
It performed poorly on training data but perfectly on validation data
- D
It reached very high training accuracy but weaker validation accuracy, indicating overfitting
Correct answer
DIt reached very high training accuracy but weaker validation accuracy, indicating overfitting
Explanation
The scratch-built CNN reached 100% training accuracy while its validation accuracy was about 69%, suggesting overfitting and weaker generalization.
- A
- 62
What is fine-tuning in the VGG 16 example?
- A
Training a model only on a validation set without changing its architecture
- B
Adapting a pretrained model's output for a new task by replacing its output layer and training the needed parameters
- C
Converting every image into a JSON architecture description
- D
Using a confusion matrix to reorder the model's layers
Correct answer
BAdapting a pretrained model's output for a new task by replacing its output layer and training the needed parameters
Explanation
The VGG 16 example removes the original 1000-class output and adds a two-class output for cats and dogs, then trains the needed parameters.
- A
- 63
Why was only minimal fine-tuning needed to adapt VGG 16 to classify cats and dogs?
- A
The new dataset contained only numerical age values
- B
The original model had no output layer to replace
- C
VGG 16 had never processed images before fine-tuning
- D
Cats and dogs were already among the classes in the data VGG 16 had been trained on
Correct answer
DCats and dogs were already among the classes in the data VGG 16 had been trained on
Explanation
The course notes that cats and dogs were included in the original ImageNet classes for which VGG 16 was trained, so little adjustment was needed.
- A
- 64
What preprocessing did the VGG 16 training procedure described in the content use?
- A
It replaced all pixel values with their class labels
- B
It subtracted the training-set mean RGB value from each pixel channel
- C
It converted every image to grayscale before training
- D
It scaled each pixel channel to a range from zero to one
Correct answer
BIt subtracted the training-set mean RGB value from each pixel channel
Explanation
The described VGG 16 preprocessing subtracts the mean RGB value computed over the training set from each pixel.
- A
- 65
Why should new images passed to a pretrained model use preprocessing consistent with its original training?
- A
Consistent preprocessing guarantees that every prediction is correct
- B
The model expects inputs processed in the same way as the data from which it learned
- C
Preprocessing consistency replaces the need for a compatible input shape
- D
The model uses preprocessing to determine its number of output classes
Correct answer
BThe model expects inputs processed in the same way as the data from which it learned
Explanation
A pretrained model should receive inputs processed in the same way as its original training data, so the course uses the corresponding Keras preprocessing function.
- A
- 66
What does freezing a layer do during fine-tuning?
- A
It turns the layer's output into a true label
- B
It prevents that layer's weights from being updated during training
- C
It changes the layer from convolutional to dense
- D
It removes the layer from the model's forward pass
Correct answer
BIt prevents that layer's weights from being updated during training
Explanation
The course freezes layers by setting them to non-trainable, which keeps their existing weights from being retrained.
- A
- 67
Why were VGG 16's pretrained layers frozen in the cats-and-dogs example?
- A
The training data contained no cat or dog images
- B
Freezing layers was required to create a validation set
- C
The model's pretrained layers had no weights to update
- D
The model had already learned useful cat-and-dog features, so only the new output layer needed training
Correct answer
DThe model had already learned useful cat-and-dog features, so only the new output layer needed training
Explanation
Because VGG 16 had already learned features for cats and dogs, the example froze its existing layers and trained the modified output layer.
- A
- 68
What result did the fine-tuned VGG 16 model achieve after five epochs in the example?
- A
About 70% training accuracy and 100% validation accuracy
- B
About 99% training accuracy and 98% validation accuracy
- C
About 85% training accuracy and 69% validation accuracy
- D
About 50% training accuracy and 50% validation accuracy
Correct answer
BAbout 99% training accuracy and 98% validation accuracy
Explanation
After five epochs, the example reported approximately 99% training accuracy and 98% validation accuracy.
- A
- 69
What does the course identify as a key advantage of MobileNet models?
- A
They always outperform larger models in accuracy
- B
They can be used only for processing numerical datasets
- C
They are lightweight, with smaller size and lower latency than many larger models
- D
They require more parameters than VGG 16 to classify images
Correct answer
CThey are lightweight, with smaller size and lower latency than many larger models
Explanation
MobileNets are presented as lightweight, low-power, low-latency models suited to tasks such as classification and detection, including use on mobile devices.
- A
- 70
What trade-off is associated with MobileNets compared with larger models such as VGG 16?
- A
They use more parameters but require fewer preprocessing steps
- B
They are larger but have lower memory requirements
- C
They are more accurate but cannot run on mobile devices
- D
They are smaller and faster but may have somewhat lower accuracy
Correct answer
DThey are smaller and faster but may have somewhat lower accuracy
Explanation
The course describes a trade-off: MobileNets are smaller and faster, while their accuracy can be somewhat lower than that of larger models.
- A
- 71
How does MobileNet preprocessing differ from the VGG 16 preprocessing described?
- A
Both models require exactly the same preprocessing operation
- B
MobileNet converts images into labels, while VGG 16 scales image dimensions
- C
MobileNet subtracts mean RGB values, while VGG 16 converts images to grayscale
- D
MobileNet scales RGB values from 0–255 to approximately −1–1, while VGG 16 subtracts mean RGB values
Correct answer
DMobileNet scales RGB values from 0–255 to approximately −1–1, while VGG 16 subtracts mean RGB values
Explanation
The course says MobileNet's preprocessing scales RGB values to a range from minus one to one, whereas VGG 16 preprocessing subtracts the training-set mean RGB value.
- A
- 72
Why did the MobileNet example resize images to 224×224 and expand their dimensions before prediction?
- A
To make the image data match VGG 16's weight values
- B
To convert one image into a batch of labels
- C
To remove the image's color channels
- D
To put the image into the expected size and shape for the model
Correct answer
DTo put the image into the expected size and shape for the model
Explanation
The image-preparation function resizes the image, converts it to an array, and expands its dimensions so it has a shape accepted by MobileNet.
- A
- 73
What does the MobileNet example's decoded prediction output show?
- A
The five training batches with the lowest loss
- B
The five model layers with the largest weights
- C
The five classes in the test set with the most samples
- D
The top five predicted ImageNet classes and their probabilities
Correct answer
DThe top five predicted ImageNet classes and their probabilities
Explanation
The Keras decoding utility displays the top five predictions from the ImageNet classes along with their probabilities.
- A
- 74
When fine-tuning MobileNet for the sign-language digits dataset, why was a new output layer added?
- A
The new dataset contained only two classes
- B
The task had ten classes, whereas the original model's output was for ImageNet classes
- C
The new output layer was needed to convert RGB images to grayscale
- D
The original MobileNet had no convolutional layers
Correct answer
BThe task had ten classes, whereas the original model's output was for ImageNet classes
Explanation
The sign-language dataset has ten classes, zero through nine, so the model was given a new ten-unit output layer.
- A
- 75
What does the
xin the MobileNet functional-model construction represent?- A
The saved weights of the original output layer
- B
The selected earlier MobileNet layers whose output is passed to the new output layer
- C
The validation split fraction
- D
The true labels for the training set
Correct answer
BThe selected earlier MobileNet layers whose output is passed to the new output layer
Explanation
In the functional-model example,
xrepresents the selected earlier MobileNet layers, and the new output layer is applied to their output. - A
- 76
How many of the final MobileNet layers were set as trainable in the described fine-tuning setup?
- A
All 88 layers
- B
Only the final output layer
- C
The first 23 layers
- D
The last 23 layers
Correct answer
DThe last 23 layers
Explanation
The example chose to make the last 23 layers trainable and freeze the earlier layers; the choice was presented as a result of experimentation rather than a universal rule.
- A
- 77
Why might the number of layers to freeze during fine-tuning need experimentation?
- A
The number is determined solely by the number of training epochs
- B
Every pretrained model requires exactly the same number of trainable layers
- C
The number must equal the number of classes in the dataset
- D
The useful choice can depend on the model and task rather than being a fixed universal number
Correct answer
DThe useful choice can depend on the model and task rather than being a fixed universal number
Explanation
The course notes that the choice of which layers to include or freeze is determined through experimentation and personal choice, rather than by a universal fixed number.
- A
- 78
What did the MobileNet fine-tuning example achieve on its test set?
- A
About 99% accuracy, with 49 correct predictions out of 50
- B
About 70% accuracy, with 35 correct predictions out of 50
- C
About 90% accuracy, with 45 correct predictions out of 50
- D
About 96% accuracy, with 96 correct predictions out of 100
Correct answer
CAbout 90% accuracy, with 45 correct predictions out of 50
Explanation
The confusion matrix showed five incorrect predictions out of 50, meaning 45 correct and approximately 90% test accuracy.
- A
- 79
What is image data augmentation?
- A
Creating modified versions of existing data, such as rotated or flipped images
- B
Replacing image samples with the model's predicted labels
- C
Removing all images that do not match the training accuracy
- D
Changing the neural network architecture after each epoch
Correct answer
ACreating modified versions of existing data, such as rotated or flipped images
Explanation
Data augmentation creates new data by modifying existing data; for images, examples include rotations, shifts, color changes, and flips.
- A
- 80
Why can data augmentation help reduce overfitting?
- A
It removes the need to compare training and validation results
- B
It guarantees that training and test sets contain identical images
- C
It can expand the training data with varied examples
- D
It forces the model to use fewer output classes
Correct answer
CIt can expand the training data with varied examples
Explanation
Augmentation can grow a training set, and a larger, more varied set can help reduce overfitting when the original dataset is too small.
- A
- 81
Which operation is an example of image augmentation described in the content?
- A
Replacing its class label with an optimizer name
- B
Removing its pixel values and keeping only its file path
- C
Flipping an image horizontally
- D
Changing the number of classes in the model
Correct answer
CFlipping an image horizontally
Explanation
The course lists horizontal or vertical flipping, rotation, and color changes as examples of image augmentation.
- A
- 82
What does an image generator's rotation or shift range control?
- A
How many neurons are in the output layer
- B
How the test labels are aligned with predictions
- C
How images are modified to create augmented examples
- D
How many epochs the model runs
Correct answer
CHow images are modified to create augmented examples
Explanation
Parameters such as rotation range, width shift, and height shift specify image transformations used to generate augmented images.
- A
- 83
Why might horizontally flipped images improve a dog-image training set?
- A
They guarantee that every dog image has the same background
- B
They can expose the model to dogs facing different directions
- C
They convert the dog images into a different output class
- D
They eliminate the need for validation data
Correct answer
BThey can expose the model to dogs facing different directions
Explanation
Flipping can add examples in which dogs face the opposite direction, making the dataset more varied and potentially improving generalization to differently oriented images.
- A

Ask anything
We've read this whole study set, so questions about it get the best answers.