1. Home
  2. Explore
  3. Computer Science
  4. Deep Learning with Keras

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Deep Learning with Keras

  • 83Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: Keras Foundations

What is Keras, as described in the course?

83 questions

  1. 1

    What is Keras, as described in the course?

    1. A

      A Python neural network API integrated with TensorFlow

    2. B

      A hardware library used only to configure GPUs

    3. C

      A database system for storing trained neural networks

    4. D

      A data-labeling tool that runs independently of Python

    Correct answer
    A

    A Python neural network API integrated with TensorFlow

    Explanation

    Keras is a neural network API written in Python and integrated with TensorFlow.

  2. 2

    What design goal is highlighted as a key strength of Keras?

    1. A

      Restricting users to a single fixed neural network architecture

    2. B

      Making model training possible only on specialized hardware

    3. C

      Enabling fast experimentation from an idea to an implementation in few steps

    4. D

      Requiring users to write every network operation from low-level primitives

    Correct answer
    C

    Enabling 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.

  3. 3

    Why does the course recommend learning more than one neural network API?

    1. A

      Every API is required to train a single neural network successfully

    2. B

      Understanding one API makes the concepts and syntactic differences in others easier to learn and compare

    3. C

      Using multiple APIs eliminates the need to understand deep learning concepts

    4. D

      Different APIs always produce identical implementations for every problem

    Correct answer
    B

    Understanding 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.

  4. 4

    How did Keras historically relate to lower-level neural network libraries?

    1. A

      It could be configured to run on TensorFlow, Theano, or CNTK

    2. B

      It required all three libraries to run together

    3. C

      It was a component of CNTK that could run only on Theano

    4. D

      It replaced TensorFlow, Theano, and CNTK as a hardware driver

    Correct answer
    A

    It 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.

  5. 5

    How is Keras described in the course's TensorFlow context?

    1. A

      It is a GPU-only package unrelated to TensorFlow

    2. B

      It is a separate library that must always be paired with CNTK

    3. C

      It is a low-level replacement for TensorFlow's computation engine

    4. D

      It is integrated with TensorFlow rather than being selected as a separate back-end library

    Correct answer
    D

    It 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.

  6. 6

    What installation command is given for installing TensorFlow with Keras?

    1. A

      Download CNTK and then install Keras separately

    2. B

      Run pip install tensorflow from the command line

    3. C

      Run pip install keras-gpu from a notebook cell

    4. D

      Install NumPy and Keras without installing TensorFlow

    Correct answer
    B

    Run pip install tensorflow from the command line

    Explanation

    Because Keras is packaged with TensorFlow, the course gives pip install tensorflow as the installation command.

  7. 7

    What programming experience is described as sufficient for the coding prerequisites?

    1. A

      Basic programming skills and some Python experience

    2. B

      Professional experience maintaining TensorFlow itself

    3. C

      Prior experience building state-of-the-art models from scratch

    4. D

      Advanced experience writing custom GPU kernels

    Correct answer
    A

    Basic programming skills and some Python experience

    Explanation

    The course states that basic programming skills and some Python experience are sufficient coding prerequisites.

  8. 8

    Is a GPU necessary to follow the course examples?

    1. A

      Yes; TensorFlow cannot train or evaluate models on a CPU

    2. B

      No; a GPU is required only for numerical datasets

    3. C

      Yes; only image-processing code can run on a GPU

    4. D

      No; the code can run on a CPU, though a GPU may offer speed advantages

    Correct answer
    D

    No; 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.

  9. 9

    In supervised learning, what does the term sample refer to?

    1. A

      An individual data point in a dataset

    2. B

      A group of model weights updated in one training step

    3. C

      The predicted class with the highest probability

    4. D

      A measure of the model's validation accuracy

    Correct answer
    A

    An 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.

  10. 10

    What are labels in a supervised learning dataset?

    1. A

      The input features after normalization

    2. B

      The set of samples reserved for validation

    3. C

      The model's hidden-layer activations

    4. D

      The target values corresponding to the samples

    Correct answer
    D

    The 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.

  11. 11

    For a sentiment task using headlines, which pair illustrates samples and labels?

    1. A

      Sentiment categories are samples, and headlines are the labels

    2. B

      Headlines are labels, and neural network layers are the samples

    3. C

      Headlines are samples, and positive or negative sentiment is the label

    4. D

      Model predictions are samples, and training epochs are the labels

    Correct answer
    C

    Headlines 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.

  12. 12

    Why should the task be understood before choosing how to format a dataset?

    1. A

      The task sets the number of GPUs available

    2. B

      The task determines which optimizer must be installed

    3. C

      The task determines the format needed to pass data to the model

    4. D

      The task makes sample labels unnecessary

    Correct answer
    C

    The 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.

  13. 13

    Which pair of arguments does the Keras fit function use for input samples and their targets?

    1. A

      x for epochs and y for batch size

    2. B

      x for input samples and y for target data

    3. C

      x for validation metrics and y for model weights

    4. D

      x for target data and y for optimizer settings

    Correct answer
    B

    x for input samples and y for target data

    Explanation

    The fit function expects x as input data or samples and y as the corresponding labels or target data.

  14. 14

    Which set contains formats the course identifies as acceptable for x input data?

    1. A

      Only a Python list, CSV file, or image filename

    2. B

      Only a TensorFlow tensor or a trained model

    3. C

      A confusion matrix, optimizer, or model summary

    4. D

      A NumPy array, TensorFlow tensor, dictionary-like mapping, tf.data.Dataset, or Keras generator

    Correct answer
    D

    A NumPy array, TensorFlow tensor, dictionary-like mapping, tf.data.Dataset, or Keras generator

    Explanation

    The course lists NumPy arrays, TensorFlow tensors, mappings, tf.data.Dataset objects, and Keras generators as accepted input formats.

  15. 15

    What format relationship must hold between the x and y arguments to fit?

    1. A

      They must use matching data formats

    2. B

      x must be a NumPy array and y must be a TensorFlow tensor

    3. C

      They must have different formats so the model can distinguish them

    4. D

      x must contain labels and y must contain samples

    Correct answer
    A

    They must use matching data formats

    Explanation

    The course says that x and y must have the same format; for example, both can be NumPy arrays.

  16. 16

    In the imagined clinical trial, what did a label of one represent?

    1. A

      The patient was assigned to the validation set

    2. B

      The patient experienced no side effects

    3. C

      The patient experienced side effects

    4. D

      The patient was younger than 65

    Correct answer
    C

    The patient experienced side effects

    Explanation

    In the generated dataset, label one represented experiencing side effects, while label zero represented no side effects.

  17. 17

    What pattern did the imagined clinical-trial data represent?

    1. A

      About 95% of younger patients had side effects, while about 95% of older patients did not

    2. B

      Side effects were assigned independently of patient age in the generated data

    3. C

      Patients of all ages had side effects at exactly the same rate

    4. D

      About 95% of older patients had side effects, while about 95% of younger patients did not

    Correct answer
    D

    About 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.

  18. 18

    Why were the generated samples and labels shuffled before training?

    1. A

      To change the labels from zero and one into class names

    2. B

      To remove ordering introduced during data generation while keeping sample-label correspondence

    3. C

      To force all samples into the validation set

    4. D

      To make the sample values fall between zero and one

    Correct answer
    B

    To 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.

  19. 19

    Why was a min-max scaler used on the age samples?

    1. A

      To rescale the values from their original range of 13–100 to a range of 0–1

    2. B

      To divide the samples into training and test sets

    3. C

      To change the number of dimensions in the neural network

    4. D

      To convert the labels from integers to text

    Correct answer
    A

    To 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.

  20. 20

    Why was the one-dimensional age data reshaped before applying the scaler's transformation?

    1. A

      The model required all ages to be converted into images

    2. B

      The transformation function did not accept one-dimensional data in its default form

    3. C

      The transformation function only accepted string labels

    4. D

      Reshaping was necessary to shuffle labels independently

    Correct answer
    B

    The 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_transform function did not accept one-dimensional data by default.

  21. 21

    What is a Keras Sequential model?

    1. A

      A linear stack of layers

    2. B

      A data iterator that sorts samples by label

    3. C

      A collection of independent models that vote on predictions

    4. D

      A training procedure that updates only output-layer weights

    Correct answer
    A

    A linear stack of layers

    Explanation

    The Sequential model is described as a linear stack of layers.

  22. 22

    In the Sequential model example, how is the input layer established?

    1. A

      The input data implicitly creates it, and the first layer's input_shape specifies the expected input shape

    2. B

      It is always a dense layer that must be listed separately before all other layers

    3. C

      It is supplied as the final layer after the output layer

    4. D

      It is created by the optimizer when training begins

    Correct answer
    A

    The input data implicitly creates it, and the first layer's input_shape specifies the expected input shape

    Explanation

    The example does not explicitly define an input layer. The input data creates it, while the first hidden layer's input_shape tells the model what input shape to expect.

  23. 23

    What does the units setting in a dense layer specify?

    1. A

      The number of classes in the validation set

    2. B

      The number of neurons or nodes in that layer

    3. C

      The number of samples in each batch

    4. D

      The number of training epochs

    Correct answer
    B

    The number of neurons or nodes in that layer

    Explanation

    The course uses units to refer to the nodes or neurons in a dense layer.

  24. 24

    Why did the example output layer have two units?

    1. A

      The model had two hidden layers

    2. B

      The task had two possible classes: side effects or no side effects

    3. C

      The input data contained two age values per patient

    4. D

      The training set was split into two batches

    Correct answer
    B

    The 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.

  25. 25

    What does the softmax activation on a multiclass output layer provide?

    1. A

      A shuffled ordering of the training samples

    2. B

      The model's optimizer state

    3. C

      Probabilities for the possible output classes

    4. D

      A normalized range of input ages only

    Correct answer
    C

    Probabilities for the possible output classes

    Explanation

    The output softmax provides probabilities for each output class, allowing the model's class predictions to be compared.

  26. 26

    What is the purpose of calling compile before training?

    1. A

      It prepares the model for training by specifying choices such as the optimizer, loss, and metrics

    2. B

      It saves the model architecture to a JSON string

    3. C

      It creates a separate test set from the validation data

    4. D

      It converts the training data into image files

    Correct answer
    A

    It 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.

  27. 27

    In the numerical example, what did a batch size of 10 mean?

    1. A

      Ten classes were predicted for each sample

    2. B

      The model trained for ten epochs

    3. C

      Ten percent of the samples were reserved for validation

    4. D

      Ten samples were processed together in one batch

    Correct answer
    D

    Ten 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.

  28. 28

    What does training for 30 epochs mean?

    1. A

      The model uses 30 output classes

    2. B

      The model processes 30 samples in total

    3. C

      The model processes the entire dataset 30 times

    4. D

      The model reserves 30% of its data for testing

    Correct answer
    C

    The 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.

  29. 29

    What does the shuffle option in fit do during training?

    1. A

      It randomly changes the model's output labels

    2. B

      It shuffles the layers in the network after every epoch

    3. C

      It shuffles the training data before it is passed through the model

    4. D

      It divides each batch into training and test samples

    Correct answer
    C

    It 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.

  30. 30

    What is the role of the verbose setting in fit?

    1. A

      It controls how many classes the model predicts

    2. B

      It selects the data format used for x and y

    3. C

      It determines whether model weights can be saved

    4. D

      It controls how much output the training function displays

    Correct answer
    D

    It controls how much output the training function displays

    Explanation

    The verbose setting controls the amount of output displayed during training; the course notes that a value of two gives the most verbose output.

  31. 31

    What is the purpose of a validation set during model training?

    1. A

      To add the validation examples to every training batch

    2. B

      To replace the labels in the training set

    3. C

      To evaluate how the model predicts on data that it does not train on

    4. D

      To update the model's weights without using training data

    Correct answer
    C

    To 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.

  32. 32

    When validation data is used during each epoch, what happens to it?

    1. A

      It is merged into the training data and shuffled with it

    2. B

      It is used only to determine the number of output classes

    3. C

      The model uses it to update its weights before training begins

    4. D

      The model predicts on it after training on that epoch's training data

    Correct answer
    D

    The 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.

  33. 33

    What is true about the validation set's role in training?

    1. A

      It is used to replace the training set during alternate epochs

    2. B

      It is used only after the model has been deployed

    3. C

      It is used to assess performance but is not used to train the model's weights

    4. D

      It is used to train the model after every training batch

    Correct answer
    C

    It 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.

  34. 34

    What pattern can indicate overfitting when comparing training and validation results?

    1. A

      Strong validation performance combined with weaker training performance

    2. B

      Similar training and validation performance at a low accuracy level

    3. C

      Strong training performance combined with notably weaker validation performance

    4. D

      Identical training and validation losses after every batch

    Correct answer
    C

    Strong 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.

  35. 35

    What does validation_split do when passed to fit?

    1. A

      It specifies how many output classes the model has

    2. B

      It combines the validation set with the test set

    3. C

      It shuffles all samples before any data is divided

    4. D

      It sets aside a fraction of the training data for validation

    Correct answer
    D

    It sets aside a fraction of the training data for validation

    Explanation

    The validation_split parameter tells Keras to set aside a fraction of the provided training data as validation data.

  36. 36

    When Keras creates a validation set using validation_split, when does the split occur relative to training-data shuffling?

    1. A

      The split occurs only after each training epoch

    2. B

      The split occurs before the training data is shuffled

    3. C

      The split occurs after the model has made predictions

    4. D

      The split occurs after the training data is converted to labels

    Correct answer
    B

    The 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.

  37. 37

    Why is it useful to shuffle data before using validation_split?

    1. A

      It guarantees that the validation accuracy will match training accuracy

    2. B

      It converts the validation examples to the same labels as the training set

    3. C

      It helps prevent the held-out portion from containing only one ordered subgroup

    4. D

      It ensures the validation set is included in model weight updates

    Correct answer
    C

    It 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.

  38. 38

    What does inference mean in the course's model workflow?

    1. A

      Using what a trained model learned to make predictions on data it has not seen before

    2. B

      Calculating the shape of the model's input layer

    3. C

      Splitting the original dataset into training and validation sets

    4. D

      Updating model weights using all available labels

    Correct answer
    A

    Using 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.

  39. 39

    What is the typical role of a test set in the workflow described?

    1. A

      It is used to update model weights during every epoch

    2. B

      It is held out and used for inference after training and validation

    3. C

      It provides the input shape for the first hidden layer

    4. D

      It replaces the validation set during model compilation

    Correct answer
    B

    It 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.

  40. 40

    Why are test labels not passed to a model when using it for inference?

    1. A

      Test labels are automatically converted into model weights

    2. B

      Passing labels would make the model unable to process input samples

    3. C

      Labels are not supported by any supervised learning model

    4. D

      Inference uses the model to produce predictions from inputs; labels, when available, are used separately to assess results

    Correct answer
    D

    Inference 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.

  41. 41

    What information does a confusion matrix provide when true test labels are available?

    1. A

      The order in which training batches were processed

    2. B

      A comparison of predicted classes with true classes

    3. C

      The pixel values used by the image preprocessor

    4. D

      The optimizer state saved during training

    Correct answer
    B

    A 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.

  42. 42

    In the course's confusion-matrix convention, where are correct predictions found?

    1. A

      Only in the final column of the matrix

    2. B

      Only in the first row of the matrix

    3. C

      Along the diagonal from the top right to the bottom left

    4. D

      Along the diagonal from the top left to the bottom right

    Correct answer
    D

    Along 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.

  43. 43

    In the clinical-trial example, what accuracy did the confusion matrix indicate on the test set?

    1. A

      About 96%, with 396 correct predictions out of 400

    2. B

      About 70%, with 300 correct predictions out of 420

    3. C

      About 50%, with 210 correct predictions out of 420

    4. D

      About 94%, with 396 correct predictions out of 420

    Correct answer
    D

    About 94%, with 396 correct predictions out of 420

    Explanation

    The example reported 396 correct predictions out of 420 total, which is approximately 94% accuracy.

  44. 44

    What does the complete Keras model-saving option preserve, according to the course?

    1. A

      Only the architecture and input shape

    2. B

      Architecture, weights, training configuration, and optimizer state

    3. C

      Only the optimizer and validation metrics

    4. D

      Only the weights and class labels

    Correct answer
    B

    Architecture, weights, training configuration, and optimizer state

    Explanation

    Calling save preserves the model architecture and weights, along with training configuration and optimizer state.

  45. 45

    Why can saving the optimizer state be useful when training is interrupted?

    1. A

      It converts the optimizer into a validation dataset

    2. B

      It can allow training to resume from the saved state after the model is loaded

    3. C

      It automatically creates new training labels

    4. D

      It prevents the model architecture from being changed

    Correct answer
    B

    It 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.

  46. 46

    What does saving a model with to_json preserve?

    1. A

      The model's test predictions and confusion matrix

    2. B

      The model architecture, but not its weights or training configuration

    3. C

      The weights and optimizer state, but not the architecture

    4. D

      The training data and its labels

    Correct answer
    B

    The model architecture, but not its weights or training configuration

    Explanation

    The to_json method saves the architecture as a JSON string. Weights and training configuration are not included.

  47. 47

    What must be done before a model reconstructed from a JSON architecture can be trained?

    1. A

      Its layers must be converted into image generators

    2. B

      Its predictions must be placed into a confusion matrix

    3. C

      Its original test set must be added to the JSON string

    4. D

      Its weights must be trained and its training configuration, such as the optimizer and loss, must be set

    Correct answer
    D

    Its 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.

  48. 48

    What does saving weights alone require when loading them later?

    1. A

      A JSON string containing the optimizer must be loaded first

    2. B

      A model with a matching architecture must be created before loading the weights

    3. C

      The original training samples must be converted to a confusion matrix

    4. D

      The weights must be loaded into any model regardless of its layer structure

    Correct answer
    B

    A 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.

  49. 49

    Why must a weights-only destination model have a compatible architecture?

    1. A

      Its optimizer must have the same name as the original model

    2. B

      It must have used the same validation split percentage

    3. C

      Its output labels must be stored in the same file name

    4. D

      Its layers and weight shapes need to match the saved weights

    Correct answer
    D

    Its 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.

  50. 50

    Which alternate architecture-serialization format is mentioned alongside JSON?

    1. A

      YAML

    2. B

      HTML

    3. C

      PNG

    4. D

      CSV

    Correct answer
    A

    YAML

    Explanation

    The course notes that a similar architecture-saving and loading process can be done using YAML instead of JSON.

  51. 51

    Why were images in the cats-versus-dogs task organized into directories by class?

    1. A

      Directory names specify the image's RGB pixel values

    2. B

      The model can only process images when each is stored in a separate model file

    3. C

      Directory structure and class names let the image generator find samples and associate them with labels

    4. D

      The directory names determine the optimizer used for each image

    Correct answer
    C

    Directory 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.

  52. 52

    What image dimensions were specified for the cats-and-dogs image batches?

    1. A

      32×3232 \times 3232×32 pixels

    2. B

      224×224224 \times 224224×224 pixels

    3. C

      100×100100 \times 100100×100 pixels

    4. D

      500×500500 \times 500500×500 pixels

    Correct answer
    B

    224×224224 \times 224224×224 pixels

    Explanation

    The image generators resized the images to a target size of 224×224224 \times 224224×224.

  53. 53

    What does flow_from_directory provide in the described image-processing workflow?

    1. A

      A list of optimized model weights

    2. B

      A saved model architecture in JSON format

    3. C

      Batches of images and their labels from a directory structure

    4. D

      A complete confusion matrix from model predictions

    Correct answer
    C

    Batches of images and their labels from a directory structure

    Explanation

    The course uses ImageDataGenerator.flow_from_directory to create directory iterators that produce batches of images and labels.

  54. 54

    Why did the test image generator use shuffle=False?

    1. A

      To preserve the mapping between test samples and their labels for evaluation

    2. B

      To prevent the training data from being shuffled during fitting

    3. C

      To make all test images belong to the same class

    4. D

      To disable resizing and preprocessing for test images

    Correct answer
    A

    To 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.

  55. 55

    Why did the course apply the same relevant preprocessing to test images as to training images?

    1. A

      Only test images need to be converted to labels

    2. B

      Preprocessing determines the order of the model's layers

    3. C

      The model should receive test data in a format consistent with the data used for training

    4. D

      Test images must have different preprocessing to avoid matching training samples

    Correct answer
    C

    The 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.

  56. 56

    What is the purpose of the input-shape setting in the first convolutional layer of the example CNN?

    1. A

      It determines how many images are in a training batch

    2. B

      It tells the model the expected image height, width, and number of color channels

    3. C

      It specifies how many classes are used in the validation set

    4. D

      It sets the size of the model's optimizer state

    Correct answer
    B

    It tells the model the expected image height, width, and number of color channels

    Explanation

    The example specifies an input shape of 224×224224 \times 224224×224 with three color channels, informing the model about the expected input images.

  57. 57

    In the example CNN, what does padding='same' do?

    1. A

      It makes every class contain the same number of images

    2. B

      It ensures all layers have the same number of filters

    3. C

      It adds padding so convolution operations do not reduce the image dimensions

    4. D

      It assigns the same probability to each output class

    Correct answer
    C

    It 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.

  58. 58

    What is the effect of the example's 2×22 \times 22×2 max-pooling operation with stride 222?

    1. A

      It doubles the number of color channels

    2. B

      It reduces the image dimensions by half

    3. C

      It increases the image dimensions by a factor of two

    4. D

      It converts each image into a label vector

    Correct answer
    B

    It reduces the image dimensions by half

    Explanation

    The course describes this max-pooling setup as cutting the image dimensions in half.

  59. 59

    Why is a convolutional network's feature map flattened before passing it to the dense output layer?

    1. A

      To create a separate validation dataset

    2. B

      To convert it into a one-dimensional representation for the dense layer

    3. C

      To change the image labels into RGB values

    4. D

      To restore image dimensions removed by max pooling

    Correct answer
    B

    To 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.

  60. 60

    Why can a two-class CNN use categorical cross-entropy with two softmax outputs, or binary cross-entropy with one sigmoid output?

    1. A

      Both setups remove the need for labels during training

    2. B

      Both setups require the model to have two input layers

    3. C

      Both setups can represent the two-class prediction task and yield equivalent results in the described case

    4. D

      The two setups are identical only when the dataset has no validation set

    Correct answer
    C

    Both 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.

  61. 61

    What did the scratch-built CNN's training and validation results suggest?

    1. A

      It could not process image data because it used a Sequential model

    2. B

      It had no output layer and therefore produced no predictions

    3. C

      It performed poorly on training data but perfectly on validation data

    4. D

      It reached very high training accuracy but weaker validation accuracy, indicating overfitting

    Correct answer
    D

    It 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.

  62. 62

    What is fine-tuning in the VGG 16 example?

    1. A

      Training a model only on a validation set without changing its architecture

    2. B

      Adapting a pretrained model's output for a new task by replacing its output layer and training the needed parameters

    3. C

      Converting every image into a JSON architecture description

    4. D

      Using a confusion matrix to reorder the model's layers

    Correct answer
    B

    Adapting 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.

  63. 63

    Why was only minimal fine-tuning needed to adapt VGG 16 to classify cats and dogs?

    1. A

      The new dataset contained only numerical age values

    2. B

      The original model had no output layer to replace

    3. C

      VGG 16 had never processed images before fine-tuning

    4. D

      Cats and dogs were already among the classes in the data VGG 16 had been trained on

    Correct answer
    D

    Cats 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.

  64. 64

    What preprocessing did the VGG 16 training procedure described in the content use?

    1. A

      It replaced all pixel values with their class labels

    2. B

      It subtracted the training-set mean RGB value from each pixel channel

    3. C

      It converted every image to grayscale before training

    4. D

      It scaled each pixel channel to a range from zero to one

    Correct answer
    B

    It 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.

  65. 65

    Why should new images passed to a pretrained model use preprocessing consistent with its original training?

    1. A

      Consistent preprocessing guarantees that every prediction is correct

    2. B

      The model expects inputs processed in the same way as the data from which it learned

    3. C

      Preprocessing consistency replaces the need for a compatible input shape

    4. D

      The model uses preprocessing to determine its number of output classes

    Correct answer
    B

    The 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.

  66. 66

    What does freezing a layer do during fine-tuning?

    1. A

      It turns the layer's output into a true label

    2. B

      It prevents that layer's weights from being updated during training

    3. C

      It changes the layer from convolutional to dense

    4. D

      It removes the layer from the model's forward pass

    Correct answer
    B

    It 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.

  67. 67

    Why were VGG 16's pretrained layers frozen in the cats-and-dogs example?

    1. A

      The training data contained no cat or dog images

    2. B

      Freezing layers was required to create a validation set

    3. C

      The model's pretrained layers had no weights to update

    4. D

      The model had already learned useful cat-and-dog features, so only the new output layer needed training

    Correct answer
    D

    The 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.

  68. 68

    What result did the fine-tuned VGG 16 model achieve after five epochs in the example?

    1. A

      About 70% training accuracy and 100% validation accuracy

    2. B

      About 99% training accuracy and 98% validation accuracy

    3. C

      About 85% training accuracy and 69% validation accuracy

    4. D

      About 50% training accuracy and 50% validation accuracy

    Correct answer
    B

    About 99% training accuracy and 98% validation accuracy

    Explanation

    After five epochs, the example reported approximately 99% training accuracy and 98% validation accuracy.

  69. 69

    What does the course identify as a key advantage of MobileNet models?

    1. A

      They always outperform larger models in accuracy

    2. B

      They can be used only for processing numerical datasets

    3. C

      They are lightweight, with smaller size and lower latency than many larger models

    4. D

      They require more parameters than VGG 16 to classify images

    Correct answer
    C

    They 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.

  70. 70

    What trade-off is associated with MobileNets compared with larger models such as VGG 16?

    1. A

      They use more parameters but require fewer preprocessing steps

    2. B

      They are larger but have lower memory requirements

    3. C

      They are more accurate but cannot run on mobile devices

    4. D

      They are smaller and faster but may have somewhat lower accuracy

    Correct answer
    D

    They 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.

  71. 71

    How does MobileNet preprocessing differ from the VGG 16 preprocessing described?

    1. A

      Both models require exactly the same preprocessing operation

    2. B

      MobileNet converts images into labels, while VGG 16 scales image dimensions

    3. C

      MobileNet subtracts mean RGB values, while VGG 16 converts images to grayscale

    4. D

      MobileNet scales RGB values from 0–255 to approximately −1–1, while VGG 16 subtracts mean RGB values

    Correct answer
    D

    MobileNet 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.

  72. 72

    Why did the MobileNet example resize images to 224×224224 \times 224224×224 and expand their dimensions before prediction?

    1. A

      To make the image data match VGG 16's weight values

    2. B

      To convert one image into a batch of labels

    3. C

      To remove the image's color channels

    4. D

      To put the image into the expected size and shape for the model

    Correct answer
    D

    To 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.

  73. 73

    What does the MobileNet example's decoded prediction output show?

    1. A

      The five training batches with the lowest loss

    2. B

      The five model layers with the largest weights

    3. C

      The five classes in the test set with the most samples

    4. D

      The top five predicted ImageNet classes and their probabilities

    Correct answer
    D

    The 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.

  74. 74

    When fine-tuning MobileNet for the sign-language digits dataset, why was a new output layer added?

    1. A

      The new dataset contained only two classes

    2. B

      The task had ten classes, whereas the original model's output was for ImageNet classes

    3. C

      The new output layer was needed to convert RGB images to grayscale

    4. D

      The original MobileNet had no convolutional layers

    Correct answer
    B

    The 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.

  75. 75

    What does the x in the MobileNet functional-model construction represent?

    1. A

      The saved weights of the original output layer

    2. B

      The selected earlier MobileNet layers whose output is passed to the new output layer

    3. C

      The validation split fraction

    4. D

      The true labels for the training set

    Correct answer
    B

    The selected earlier MobileNet layers whose output is passed to the new output layer

    Explanation

    In the functional-model example, x represents the selected earlier MobileNet layers, and the new output layer is applied to their output.

  76. 76

    How many of the final MobileNet layers were set as trainable in the described fine-tuning setup?

    1. A

      All 88 layers

    2. B

      Only the final output layer

    3. C

      The first 23 layers

    4. D

      The last 23 layers

    Correct answer
    D

    The 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.

  77. 77

    Why might the number of layers to freeze during fine-tuning need experimentation?

    1. A

      The number is determined solely by the number of training epochs

    2. B

      Every pretrained model requires exactly the same number of trainable layers

    3. C

      The number must equal the number of classes in the dataset

    4. D

      The useful choice can depend on the model and task rather than being a fixed universal number

    Correct answer
    D

    The 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.

  78. 78

    What did the MobileNet fine-tuning example achieve on its test set?

    1. A

      About 99% accuracy, with 49 correct predictions out of 50

    2. B

      About 70% accuracy, with 35 correct predictions out of 50

    3. C

      About 90% accuracy, with 45 correct predictions out of 50

    4. D

      About 96% accuracy, with 96 correct predictions out of 100

    Correct answer
    C

    About 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.

  79. 79

    What is image data augmentation?

    1. A

      Creating modified versions of existing data, such as rotated or flipped images

    2. B

      Replacing image samples with the model's predicted labels

    3. C

      Removing all images that do not match the training accuracy

    4. D

      Changing the neural network architecture after each epoch

    Correct answer
    A

    Creating 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.

  80. 80

    Why can data augmentation help reduce overfitting?

    1. A

      It removes the need to compare training and validation results

    2. B

      It guarantees that training and test sets contain identical images

    3. C

      It can expand the training data with varied examples

    4. D

      It forces the model to use fewer output classes

    Correct answer
    C

    It 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.

  81. 81

    Which operation is an example of image augmentation described in the content?

    1. A

      Replacing its class label with an optimizer name

    2. B

      Removing its pixel values and keeping only its file path

    3. C

      Flipping an image horizontally

    4. D

      Changing the number of classes in the model

    Correct answer
    C

    Flipping an image horizontally

    Explanation

    The course lists horizontal or vertical flipping, rotation, and color changes as examples of image augmentation.

  82. 82

    What does an image generator's rotation or shift range control?

    1. A

      How many neurons are in the output layer

    2. B

      How the test labels are aligned with predictions

    3. C

      How images are modified to create augmented examples

    4. D

      How many epochs the model runs

    Correct answer
    C

    How 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.

  83. 83

    Why might horizontally flipped images improve a dog-image training set?

    1. A

      They guarantee that every dog image has the same background

    2. B

      They can expose the model to dogs facing different directions

    3. C

      They convert the dog images into a different output class

    4. D

      They eliminate the need for validation data

    Correct answer
    B

    They 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.

Question 1 of 83
Question 1 of 83

Ask anything

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

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent