我有一个重塑问题,但是我不知道如何为inputA调整尺寸。 我不断收到错误消息:
ValueError:conv1d_29层的输入0与该层不兼容:预期ndim = 3,找到的ndim = 2。收到完整的图形:[无,3750]
也许有人可以帮助我,为我提供适当尺寸的提示:
# reshape after CV, need to merge all the columns before CV, shouldn't be reshaped in order to match the dimensions
# X_train=X_train.reshape(len(X_train),5200,1)
# X_test=X_test.reshape(len(X_test),5200,1)
def create_model():
n_timesteps=3750
n_features=1
n_outputs=1
inputA = Input(shape=(X_train.shape[1:]))
inputB = Input(shape=(1,))
inputC = Input(shape=(1,))
inputD = Input(shape=(1,))
x = InputLayer(input_shape=(None, X_train.shape[1:][0],1))(inputA)
x = Conv1D(64, 3, activation='relu')(inputA) #, input_shape=(None, 3750, n_features)
x = Conv1D(64, 3, activation='relu')(x)
x = MaxPooling1D(3)(x)
x = Conv1D(128, 3, activation='relu')(x)
x = Conv1D(128, 3, activation='relu')(x)
# x = Dropout(0.5)(x)
x = Flatten()(x)
concatenated_features = concatenate([x,inputB,inputC,inputD])
x = Dense(64,activation='relu')(concatenated_features)
# Check for the position of the dropout
# x = Dropout(0.5)(x)
x = Dense(n_outputs, activation='sigmoid')(x)
model = Model(inputs=[inputA, inputB,inputC,inputD], outputs=x)
model.compile(loss='binary_crossentropy',
optimizer=Adam(lr=lr),
metrics=['accuracy'])
print(model.summary())
return model
仅提供更多信息: 我的inputA是X_train的输入,其尺寸为(318,3750)。