x 和 y 必须具有相同的第一维,但具有形状 (9,) 和 (4,)

问题描述 投票:0回答:0
y_pred = fig.predict(x.reshape(1, -1)).reshape(-1)
colors_dark = ["#1F1FIF", "#313131", "#636363", "#AEAEAE", "#DADADA"] 
colors_red = ["#331313", "#582626", "#9E1717", "#D35151", "#E9B4B4"] 
colors_green=[ "# 01411C", "#4B6F44", "#4F7942", "#74C365", "#D0F0C0"]
filterwarnings("ignore")
epochs =[ i for i in range(9)]
fig, ax = plt.subplots(1, 2,figsize=(14,7))
train_acc1 = model_history.history[ "accuracy" ] 
train_lossl = model_history.history[ "loss"]
val_acc1 = model_history.history[ "val_accuracy" ]
val_loss1 = model_history.history[ "val_loss" ]
fig.text(s='Epochs vs. Training and Validation Accuracy/Loss',size=18,fontweight='bold',      

fontname='monospace',color=colors_dark[1],y=1,x=0.28,alpha=0.8)
sns.despine()


ax[0].plot(epochs,train_acc1,marker='o',markerfacecolor=colors_green[2],color=colors_green[3],
label="Training Accuracy")
ax[0].plot(epochs, val_acc1,  

marker='o',markerfacecolor=colors_red[2],color=colors_red[3],label="Validation Accuracy")
ax[0].legend(frameon=False)
ax[0].set_xlabel("Epochs")
ax[0].set_ylabel("Accuracy")
sns.despine()
ax[1].plot(epochs[:],train_loss1,marker='o',markerfacecolor=colors_green[2],
color=colors_green[3],label="Training Loss")
ax[1].plot(epochs[:],val_loss1,marker="o",markerfacecolor=colors_red[2],color=colors_red[3],
label = "Validation Loss")
ax[1].legend(frameon=False)
ax[1].set_xlabel("Epochs")
ax[1].set_ylabel("Training & Validation Loss")
fig.show()

这是我的代码。但是当我执行它时,它说 x 和 y 必须具有第一维但具有形状 9 和 4。请帮助我!!!!任何帮助将不胜感激

python tensorflow keras valueerror ml
© www.soinside.com 2019 - 2024. All rights reserved.