Exercise

Changing batch sizes

You've seen models are usually trained in batches of a fixed size. The smaller a batch size, the more weight updates per epoch, but at a cost of a more unstable gradient descent. Specially if the batch size is too small and it's not representative of the entire training set.

Let's see how different batch sizes affect the accuracy of a simple binary classification model that separates red from blue dots.

You'll use a batch size of one, updating the weights once per sample in your training set for each epoch. Then you will use the entire dataset, updating the weights only once per epoch.

Instructions 1/2

undefined XP
  • 1

    Use get_model() to get a new, already compiled, model, then train your model for 5 epochs with a batch_size of 1.

  • 2

    Now train a new model with batch_size equal to the size of the training set.