答案 0 :(得分:0)
使用功能性API进行Keras实现
from keras.models import Model
from keras.layers import Dense, Input, concatenate
def createModel( inp_1_shape, inp_2_shape):
first_input = Input(shape = (inp_1_shape,))
first_dense = Dense(1, )(first_input)
second_input = Input(shape = (inp_2_shape,))
second_dense = Dense(1, )(second_input)
merge = concatenate([first_dense, second_dense])
merge = Dense(2, )(merge)
merge = Dense(3, )(merge)
merge = Dense(1, )(merge)
model = Model(inputs=[first_input, second_input], outputs=merge)
model.compile(optimizer='adam', loss='mse', metrics=['accuracy'])
return model
只需调用此函数,它将返回一个keras模型,您可能需要仔细检查每一层中的神经元数量,但除此之外,您会没事的。
快乐培训