Session Ready
Exercise

Fit neural net with custom loss function

Now we'll use the custom loss function we just created. This will enable us to alter the model's behavior in useful ways particular to our problem -- it's going to try to force the model to learn how to at least predict price movement direction correctly. All we need to do now is set the loss argument in our .compile() function to our function name, sign_penalty. We'll examine the training loss again to make sure it's flattened out.

Instructions
100 XP
  • Set the input_dim of the first neural network layer to be the number of columns of scaled_train_features with the .shape[1] property.
  • Use the custom sign_penalty loss function to .compile() our model_2.
  • Plot the loss from the history of the fit. The loss is under history.history['loss'].