IniziaInizia gratis

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.

Questo esercizio fa parte del corso

Introduction to Deep Learning in Python

Visualizza il corso

Istruzioni dell'esercizio

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

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

# Fit the model
____
Modifica ed esegui il codice