編譯模型
本練習屬於課程
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)