您好,我的预测模型出现此错误。我从具有4个输入和4个输出的Excel文件中获取数据。我是深度学习的新手。我可以看到它与y_test有关,但我不知道该写些什么。这是我的代码。感谢您的提前帮助
df = pd.read_excel ("C:/Users/hayri/Desktop/aa.xlsx")
xdata = df
print(xdata)
min_max_scaler = preprocessing.MinMaxScaler()
x_scaled = min_max_scaler.fit_transform(xdata)
df = pd.read_excel ("C:/Users/hayri/Desktop/bb.xlsx")
ydata = df
min_max_scaler = preprocessing.MinMaxScaler()
y_scaled = min_max_scaler.fit_transform(ydata)
(x_train, x_test, y_train, y_test)= train_test_split(x_scaled,y_scaled,test_size = 0.2,random_state=0)
conv = Sequential()
conv.add(Conv1D(filters=32, kernel_size=4, activation='relu', input_shape=(4, 4)))
conv.add(Dropout(0.5))
conv.add(MaxPooling1D(3))
conv.add(Flatten())
conv.add(Dense(4, activation = 'sigmoid'))
sgd = optimizers.SGD(lr=0.3, momentum = 0.6, decay = 0, nesterov = False)
conv.compile(loss = 'binary_crossentropy', optimizer ='sgd', metrics = ['accuracy'])
history=conv.fit(x_train, y_train, batch_size =10, epochs =200,validation_data=(x_test,y_test), verbose = 1)
score = conv.evaluate(x_test, y_test, batch_size=10)
y_test=np.argmax(y_test, axis=1)
y_pred = conv.predict(x_test,batch_size=64)
y_pred = np.argmax(y_pred, axis=1)
results = confusion_matrix(y_test, y_pred)
sns.heatmap(results,cmap="Blues")
accuracy = conv.evaluate(x_test, y_test)
print('Accuracy: %.2f' % (accuracy*100))
model.compile(loss = 'binary_crossentropy', optimizer ='adam', metrics = ['accuracy'])
history=model.fit(x_train, y_train, batch_size =10, epochs =200,validation_data=(x_test,y_test), verbose = 1)
score = model.evaluate(x_test, y_test, batch_size=10)
y_pred = model.predict(x_test,batch_size=64)
y_pred = np.argmax(y_pred, axis=1)