Python ValueError:层conv1d_29的输入0与层不兼容
我有一个重塑的问题,但我不知道如何修复我的输入维度。 我不断发现错误: ValueError:层conv1d_29的输入0与层不兼容:预期ndim=3,发现ndim=2。收到完整形状:[无,3750] 也许有人可以帮助我,给我一个关于正确维度的提示:Python ValueError:层conv1d_29的输入0与层不兼容,python,tensorflow,keras,Python,Tensorflow,Keras,我有一个重塑的问题,但我不知道如何修复我的输入维度。 我不断发现错误: 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_tra
# 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
仅供进一步参考:
我的输入是尺寸为(3183750)的X_列的输入