Aan de slagGa gratis aan de slag

Fitting the model

You're at the most fun part. You'll now fit the model. Recall that the data to be used as predictive features is loaded in a NumPy array called predictors and the data to be predicted is stored in a NumPy array called target. Your model is pre-written and it has been compiled with the code from the previous exercise.

Deze oefening maakt deel uit van de cursus

Introduction to Deep Learning in Python

Cursus bekijken

Oefeninstructies

  • Fit the model. Remember that the first argument is the predictive features (predictors), and the data to be predicted (target) is the second argument.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# 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
model.compile(optimizer='adam', loss='mean_squared_error')

# Fit the model
____
Code bewerken en uitvoeren