# Plot loss curve plt.figure(figsize=(10, 4)) plt.subplot(1, 2, 1) plt.plot(loss_history) plt.title('Training Loss') plt.xlabel('Epoch') plt.ylabel('Loss') plt.yscale('log') plt.grid(True, alpha=0.3) plt.subplot(1, 2, 2) plt.plot(loss_history[-100:]) # Last 100 epochs plt.title('Training Loss (Last 100 Epochs)') plt.xlabel('Epoch') plt.ylabel('Loss') plt.grid(True, alpha=0.3) plt.tight_layout() plt.show() print(f"Final loss: {loss_history[-1]:.6f}")