1. Home
  2. Explore
  3. Computer Science
  4. Building Keras Models

Study methods

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

Building Keras Models

  • 32Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: Training Fundamentals
  • spaceFlip card
  • KI knew it
  • DI didn't know it
  • ←Previous card
  • →Next card

What is an epoch in neural network training?

Tap to flipClick to flipspace

One complete pass through the entire training dataset.

Or swipe the card

32 cards

  1. What is an epoch in neural network training?

    One complete pass through the entire training dataset.

  2. What is a batch in stochastic gradient descent (SGD)?

    A small subset of the training data (e.g., 32 samples) processed together in one forward/backward pass.

  3. How does gradient descent differ from stochastic gradient descent in terms of weight updates per epoch?

    Gradient descent performs one weight update per epoch, while SGD performs one update per batch (multiple updates per epoch).

  4. What is overfitting and how does it relate to model complexity?

    Overfitting occurs when the model fits the training data too well, capturing noise, and performs poorly on new data. It happens as model complexity increases beyond a sweet spot.

  5. What is early stopping?

    A regularization technique that stops training when the validation loss stops improving (e.g., starts increasing) to prevent overfitting.

  6. What is dropout?

    A regularization technique that randomly drops a fraction of neurons during training, forcing the network to learn redundant representations.

  7. What is a tensor?

    A generalization of numbers, vectors, and matrices to higher dimensions. Tensors have a rank (number of dimensions) and shape.

  8. Give examples of tensors of rank 0, 1, 2, 3, and 4.

    Rank 0: a single number (e.g., 5). Rank 1: a list (e.g., [1,2,3]). Rank 2: a table (e.g., 2D array). Rank 3: a list of tables (e.g., grayscale image batch). Rank 4: a list of rank-3 tensors (e.g., color video).

  9. What are the key features of TensorFlow?

    Automatic gradient computation, built-in optimizers (like SGD, Adam), distribution across servers, and GPU/TPU support.

  10. What does Keras provide on top of TensorFlow?

    Convenient APIs for building layers, activation functions, preprocessing, training, metrics, and pre-trained models.

  11. Why must categorical variables be one-hot encoded for neural networks?

    Neural networks require numerical inputs; one-hot encoding converts categorical variables into binary vectors that are interpretable as numeric inputs.

  12. Why must numeric variables be standardized (normalized) for neural networks?

    To ensure all features have similar ranges (e.g., mean 0, standard deviation 1), which improves convergence during training.

  13. Why should the data split (train/test) be done before normalization?

    To prevent information from the test set (e.g., its mean and standard deviation) from leaking into the preprocessing, which would invalidate the test set's role as unseen data.

  14. What is the architecture of the heart disease prediction model?

    Input layer (29 features), one hidden dense layer with 16 ReLU neurons, output dense layer with 1 sigmoid neuron.

  15. How many parameters are in the heart disease model?

    497 parameters: (29×16 + 16) + (16×1 + 1) = 464 + 17 = 497.

  16. What loss function is used for binary classification with a sigmoid output?

    Binary cross-entropy.

  17. What optimizer is commonly used as a default in modern deep learning?

    Adam (Adaptive Moment Estimation).

  18. What is the purpose of the compilation step in Keras?

    To configure the model for training by specifying the optimizer, loss function, and metrics. It also optimizes the model for parallel execution.

  19. What arguments does model.fit typically take?

    x (input data), y (labels), epochs, batch_size, verbose, validation_split (or validation_data).

  20. What is the history object returned by model.fit?

    A dictionary containing training and validation loss and metric values for each epoch.

  21. How do you evaluate a trained model on a test set in Keras?

    Use model.evaluate(test_x, test_y), which returns the loss and any specified metrics on the test data.

  22. What is the baseline accuracy for the heart disease dataset?

    72.6% (the proportion of the majority class, no heart disease).

  23. How are grayscale images represented digitally?

    As a 2D array (table) of pixel intensities, where each value ranges from 0 (black) to 255 (white).

  24. How are color images represented?

    As three 2D arrays (channels) for red, green, and blue (RGB), each with values from 0 to 255.

  25. What is flattening in the context of image input?

    Converting a 2D image (or higher-dimensional tensor) into a 1D vector by concatenating rows (or all elements).

  26. What are the different image classification tasks beyond basic classification?

    Localization (bounding box around object), object detection (multiple objects with boxes), semantic segmentation (pixel-wise classification), instance segmentation (pixel-wise classification separating instances).

  27. What is the baseline accuracy for a balanced 10-class classification problem?

    10% (random guessing or predicting the most frequent class).

  28. What is the architecture for the Fashion-MNIST model?

    Flatten layer (28×28→784), one hidden dense layer with 256 ReLU neurons, output dense layer with 10 neurons and softmax activation.

  29. What is the softmax function and why is it used for multi-class classification?

    Softmax converts a vector of raw scores into probabilities that sum to 1. It exponentiates each score and divides by the sum of all exponentiated scores.

  30. What are the different loss functions for multi-class classification depending on output encoding?

    For sparse integer labels: sparse_categorical_crossentropy. For one-hot encoded labels: categorical_crossentropy.

  31. How is the Fashion-MNIST dataset loaded in Keras?

    Using tf.keras.datasets.fashion_mnist.load_data().

  32. What is the shape of the training data and labels in Fashion-MNIST?

    Train images: (60000, 28, 28), a rank-3 tensor. Train labels: (60000,), a vector of integers 0-9.

Card 1 of 32
Card 1 of 32

Ask anything

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

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent