1 回答
TA贡献1831条经验 获得超4个赞
如果我理解正确,S本质上只是模型的另一个输入。在这种情况下,您可以为 S 添加第二个输入层,并在训练期间将 S 传递到模型。这将使以下内容变为:
input_fts = Input(shape=(self.input_length,), name='ae_input')
S_in = Input(shape=(312,), name='s_input')
encoded = Dense(1826, activation='relu', name='e_dense1')(input_fts)
encoded = Dense(932, activation='relu', name='e_dense2')(encoded)
encoded = Dense(428, activation='relu', name='e_dense3')(encoded)
encoded = Dropout(0.1)(encoded)
code = Dense(self.encoding_length, activation='relu', name='code')(encoded)
decoded = Dense(428, activation='relu', name='d_dense4')(code)
decoded = Dense(932, activation='relu', name='d_dense5')(decoded)
decoded = Dense(1826, activation='relu', name='d_dense6')(decoded)
output_fts = Dense(self.output_length, activation='relu', name='ae_output')(decoded)
ae = Model(inputs=[input_fts, S_in], outputs=output_fts)
ae.add_loss(self.lambda_ * K.mean(K.square(S_in-code)))
ae.add_loss(K.mean(K.square(input_fts - output_fts)))
ae.compile(optimizer='adam')
然后,传递正常输入和 S 以使用列表进行预测(请参阅 https://keras.io/getting-started/functional-api-guide/)。
添加回答
举报