model= Model(input=[x1,x2], output=[y1, y2])
model.compile((optimizer='sgd',
loss=tf.keras.losses.MeanSquared)```
,其中y1的取值范围为[0,1]和Y2取值范围为[0,100],x1,x2取值范围为[0,1]
分别规范化。先获取训练样本的统计信息
mu = [np.mean(y1_train), np.mean(y2_train)]
std = [np.std(y1_train), np.std(y2_train)]
然后对训练集和验证集的输出进行归一化
y_train_normalized = [(y[i] - mu[i]) / std[i] for i in range(2)]
y_val_normalized = [(y[i] - mu[i]) / std[i] for i in range(2)]
训练后,要恢复正确的预测,只需使用
y_recovered = [y_pred[i] * std[i] + mu[i] for i in range(2)]
必要时对x
做同样的处理(当然是对x_train
的统计)。