Im not sure what im doing wrong. My error is ValueError: x and y must have same first dimension, but have shapes (5,) and (1,)

  keras, python

My error is ValueError: x and y must have same first dimension, but have shapes (5,) and (1,)
Im not sure what I’m doing wrongly.

acc = history.history['accuracy']
val_acc = history.history['val_accuracy']

loss = history.history['loss']
val_loss = history.history['val_loss']

epochs_range = range(5)

plt.figure(figsize = (8, 8))
plt.subplot(2, 1, 1)
plt.plot(epochs_range, acc, label = 'Training Accuracy')
plt.plot(epochs_range, val_acc, label = 'Validation Accuracy')
plt.legend(loc = 'lower right')
plt.title('Training and Validation Accuracy')

plt.subplot(2, 1, 2)
plt.plot(epochs_range, loss, label = 'Training Loss')
plt.plot(epochs_range, val_loss, label = 'Validation Loss')
plt.legend(loc = 'upper right')
plt.title('Training and Validation Loss')
plt.show()

Source: Python Questions

LEAVE A COMMENT