我有两个形状数据集
>>> X_st.shape
(Batch_size,10,34)
>>> X_tim.shape
(Batch_size,10,8)
以及以下型号
from tensorflow.keras import layers,Input,Model
# Branch 1 for X_st
Input1 = Input(shape = (10,34) ,name='stat')
Dense1 = layers.Dense(35,activation='relu')(Input1)
# Branch 2 for X_tim
Input2 = Input(shape = (10,8) ,name='tim')
RNN1 = layers.LSTM(10)(Input2)
# Concatination
concatenated = layers.concatenate([Dense1 , RNN1 ],axis=-1)
Final = layers.Dense(44,activation='relu')(concatenated)
output = layers.Dense(1,activation='sigmoid')(Final)
model = Model([Input1 , Input2], output)
model.compile(optimizer='rmsprop',loss='binary_crossentropy',metrics=['acc'])
我的目标是合并分支1和2的输出,并将其传递给Final
,最后传递给output
。
运行时出现以下错误
ValueError: A `Concatenate` layer requires inputs with matching shapes except for the concat axis. Got inputs shapes: [(None, 10, 35), (None, 10)]
我必须重塑输出以实现这一点吗?如果可以的话怎么办?