如何在Keras中连接自定义层和顺序层

时间:2019-10-01 17:53:26

标签: python keras keras-layer

我想在下图中实现神经网络,但是我不知道如何将前神经元连接到后顺序层。需要什么工具?我是外国人,我不擅长使用此论坛。如果格式有误,希望大家指出来,谢谢。

O O O Fully connected O O O O O O The top two are fully connected to the bottom three O O O O O O O O O

我已经写了前两层,但是连接第二层和第三层时出现问题。我试图添加一个图层。首先使用model.add进行强化,然后通过串联与先前的MergeDense合并,但是失败了,我将在下面显示我的代码。

ts = Sequential()

ts.add(layers.Dense(32,input_shape=(2,)))
ts.add(layers.Dense(32))

merge_seven = concatenate([merge_one, merge_two, merge_forth, merge_five])

model = Model(inputs=[first_input, second_input, third_input, forth_input, five_input, six_input], outputs=[ts])
ada_grad = Adagrad(lr=0.1, epsilon=1e-08, decay=0.0)
model.compile(optimizer=ada_grad, loss='binary_crossentropy',
               metrics=['accuracy'])
ValueError: Output tensors to a Model must be the output of a Keras `Layer` (thus holding past layer metadata). Found: <keras.engine.sequential.Sequential object at 0x000001CB60858C18>

0 个答案:

没有答案
相关问题