Compiling the model
You're now going to compile the model you specified earlier. To compile the model, you need to specify the optimizer and loss function to use. In the video, Dan mentioned that the Adam optimizer is an excellent choice. You can read more about it as well as other Keras optimizers here, and if you are really curious to learn more, you can read the original paper that introduced the Adam optimizer.
In this exercise, you'll use the Adam optimizer and the mean squared error loss function. Go for it!
Questo esercizio fa parte del corso
Introduction to Deep Learning in Python
Istruzioni dell'esercizio
- Compile the model using
model.compile(). Youroptimizershould be'adam'and thelossshould be'mean_squared_error'.
Esercizio pratico interattivo
Prova a risolvere questo esercizio completando il codice di esempio.
# Import necessary modules
from tensorflow.keras.layers import Dense
from tensorflow.keras.models import Sequential
# Specify the model
n_cols = predictors.shape[1]
model = Sequential()
model.add(Dense(50, activation='relu', input_shape = (n_cols,)))
model.add(Dense(32, activation='relu'))
model.add(Dense(1))
# Compile the model
____
# Verify that model contains information from compiling
print("Loss function: " + model.loss)