Get startedGet started for free

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.

This exercise is part of the course

Introduction to Deep Learning in Python

View Course

Exercise instructions

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

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# 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
____
Edit and Run Code