【发布时间】:2023-04-10 12:05:01
【问题描述】:
我正在从事一个涉及 10 个输入(X1、X2、...、X10)并预测 3 个输出(Y1、Y2、Y3)的项目。我在 Python 中使用 Keras 包和 Tensorflow 的后端。我已经建立了一个人工神经网络,经过训练并展示了不错的预测。
def build_model()
input_layer = Input(shape=(len(train .columns),))
first = Dense(units='1024', activation='relu')(input_layer)
second = Dense(units='512', activation='relu')(first)
third = Dense(units='512', activation='relu')(second)
# first output will be fed from the third dense
y1_output = Dense(units='1', name='y1_output')(third)
fourth = Dense(units='256', activation='relu')(third)
# second output will be fed from the fourth dense
y2_output = Dense(units='1', name='y2_output')(fourth)
fifth = Dense(units='64', activation='relu')(fourth)
# third output will be fed from the fifth dense
y3_output = Dense(units='1', name='y3_output')(fifth)
# Define the model with the input layer and a list of output layers
model = Model(inputs=input_layer, outputs=[y1_output, y2_output, y3_output])
return model
model = build_model()
print(model.summary())
optimizer = tf.keras.optimizers.Adam(learning_rate=0.001)
model.compile(optimizer=optimizer,
loss={'y1_output': 'mse',
'y2_output': 'mse',
'y3_output': 'mse'},
metrics={'y1_output': tf.keras.metrics.RootMeanSquaredError(),
'y2_output': tf.keras.metrics.RootMeanSquaredError(),
'y3_output': tf.keras.metrics.RootMeanSquaredError()})
如何确定产生最佳输出(Y1、Y2、Y3)的 10 个输入的值?我不确定遗传算法是否可以帮助解决这个问题,如果可以,我不知道如何实现它。任何建议或见解将不胜感激。
【问题讨论】:
标签: python tensorflow keras optimization neural-network