Session Ready
Exercise

Preparing to batch train

Before we can train a linear model in batches, we must first define variables, a loss function, and an optimization operation. In this exercise, we will prepare to train a model that will predict price_batch, a batch of house prices, using size_batch, a batch of lot sizes in square feet. In contrast to the previous lesson, we will do this by loading batches of data using pandas, converting it to numpy arrays, and then using it to minimize the loss function in steps.

Variable(), keras(), and float32 have been imported for you. Note that you should not set default argument values for either the model or loss function, since we will generate the data in batches during the training process.

Instructions
100 XP
  • Define intercept as having an initial value of 10.0 and a data type of 32-bit float.
  • Define the model to return the predicted values using intercept, slope, and features.
  • Define a function called loss_function() that takes intercept, slope, targets, and features as arguments and in that order. Do not set default argument values.
  • Define the mean squared error loss function using targets and predictions.