Session Ready
Exercise

Training a linear model in batches

In this exercise, we will train a linear regression model in batches, starting where we left off in the previous exercise. We will do this by stepping through the dataset in batches and updating the model's variables, intercept and slope, after each step. This approach will allow us to train with datasets that are otherwise too large to hold in memory.

Note that the loss function,loss_function(intercept, slope, targets, features), has been defined for you. Additionally, keras has been imported for you and numpy is available as np. The trainable variables should be entered into var_list in the order in which they appear as loss function arguments.

Instructions
100 XP
  • Use the .Adam() optimizer.
  • Load in the data from 'kc_house_data.csv' in batches with a chunksize of 100.
  • Extract the price column from batch, convert it to a numpy array of type 32-bit float, and assign it to price_batch.
  • Complete the loss function, fill in the list of trainable variables, and perform minimization.