【发布时间】:2018-12-28 18:15:49
【问题描述】:
我正在关注官方的 TensorFlow with Keras 教程,但我卡在这里:Predict house prices: regression - Create the model
为什么要在预测连续值的任务中使用激活函数?
代码是:
def build_model():
model = keras.Sequential([
keras.layers.Dense(64, activation=tf.nn.relu,
input_shape=(train_data.shape[1],)),
keras.layers.Dense(64, activation=tf.nn.relu),
keras.layers.Dense(1)
])
optimizer = tf.train.RMSPropOptimizer(0.001)
model.compile(loss='mse', optimizer=optimizer, metrics=['mae'])
return model
【问题讨论】:
标签: machine-learning neural-network keras regression activation-function