【发布时间】:2020-11-30 00:18:51
【问题描述】:
我必须输入我想合并到一个网络中的输入,所以它应该是这样的:
input1 input2
| |
| |
hidden hidden
Merged
我试过这段代码:
b1_part = Sequential()
b1_part.add(Dense(units=b1_X_train.shape[1],activation='tanh', activity_regularizer=regularizers.l2(1e-2)))
b1_part.add(Dropout(0.5))
b1_part.add(Dense(units=b1_X_train.shape[1]/4,activation='tanh', activity_regularizer=regularizers.l2(1e-2)))
b2_part = Sequential()
b2_part.add(Dense(units=b2_X_train.shape[1],activation='tanh', activity_regularizer=regularizers.l2(1e-2)))
b2_part.add(Dropout(0.5))
b2_part.add(Dense(units=b2_X_train.shape[1]/4,activation='tanh', activity_regularizer=regularizers.l2(1e-2)))
result = Concatenate(axis=1)([b1_part, b2_part])
optimizer = Adagrad()
result.compile(optimizer=optimzier, loss=BinaryFocalLoss(gamma=2),
metrics=['accuracy'])
但是得到了:
ValueError: Layer concatenate_10 was called with an input that isn't a symbolic tensor. Received type: <class 'tensorflow.python.keras.engine.sequential.Sequential'>. Full input: [<tensorflow.python.keras.engine.sequential.Sequential object at 0x7fb1cbf97048>, <tensorflow.python.keras.engine.sequential.Sequential object at 0x7fb1cbeb5358>]. All inputs to the layer should be tensors.
知道为什么吗?
【问题讨论】:
标签: python tensorflow keras deep-learning concatenation