i trying to run this plot but is said error: can’t convert CUDA tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first , anyone know why?
def plot_training_history(history):
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(18, 6))
ax1.plot(history['train_loss'], label='train loss')
ax1.plot(history['val_loss'], label='validation loss')
ax1.xaxis.set_major_locator(MaxNLocator(integer=True))
ax1.set_ylim([-0.05, 1.05])
ax1.legend()
ax1.set_ylabel('Loss')
ax1.set_xlabel('Epoch')
ax2.plot(history['train_acc'], label='train accuracy')
ax2.plot(history['val_acc'], label='validation accuracy')
ax2.xaxis.set_major_locator(MaxNLocator(integer=True))
ax2.set_ylim([-0.05, 1.05])
ax2.legend()
ax2.set_ylabel('Accuracy')
ax2.set_xlabel('Epoch')
fig.suptitle('Training history')