连接两个数据集以提供两个模型时遇到问题,请帮助解决

问题描述 投票:0回答:0

连接两个数据集以提供两个模型时遇到问题,请帮助解决

这是我的架构示例

# concatenate the two datasets
network_data = pd.concat([network_data1, network_data2], ignore_index=True)
# separate the input features and labels
X = network_data.drop('Label', axis=1)
y = network_data['Label']

# split the data into train and test sets
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

# create the first model
model1 = Model(inputs=input1, outputs=output1)

# train the first model
model1.compile()
model1.fit()

# create the second model
model2 = Model(inputs=input2, outputs=output2)

# train the second model
model2.compile()
model2.fit()

# concatenate the output of the two models
concatenated = concatenate([model1.output, model2.output])

# create the common model
output3 = Dense()(concatenated)
model = Model(inputs=[model1.input, model2.input], outputs=output3)

# compile the common model
model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['accuracy'])

# train the common model
model.fit([X_train, y_train], epochs=10, batch_size=32, validation_data=([X_test, y_test]))

错误是:

ValueError: Error when checking input: expected input_20 to have 3 dimensions, but got array with shape (100000, 5)
python pandas numpy deep-learning artificial-intelligence
© www.soinside.com 2019 - 2024. All rights reserved.