编译模型
本练习是课程的一部分
Python 深度学习入门
练习说明
- 使用
model.compile()编译模型。将optimizer设为'adam',loss设为'mean_squared_error'。
交互式实操练习
通过完成这段示例代码来试试这个练习。
# 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)