| import matplotlib.pyplot as plt |
| import numpy as np |
| import os |
|
|
| |
| os.makedirs('figures', exist_ok=True) |
|
|
| |
| |
| epochs = np.arange(0, 501, 10) |
|
|
| |
| laplacian_loss = [14.4778, 6.3182, 4.9672, 4.0325, 3.3150, 2.7156, 2.2783, 1.9851, 1.8276, 1.7388, |
| 1.6653, 1.6503, 1.6100, 1.5919, 1.5719, 1.5576, 1.5600, 1.5448, 1.5532, 1.5382, |
| 1.5199, 1.5267, 1.5356, 1.5368, 1.5265, 1.5212, 1.5289, 1.5188, 1.5152, 1.5275, |
| 1.5260, 1.5241, 1.5245, 1.5297, 1.5155, 1.5245, 1.5253, 1.5210, 1.5232, 1.5164, |
| 1.5133, 1.5276, 1.5229, 1.5157, 1.5104, 1.5204, 1.5361, 1.5188, 1.5305, 1.5170, 1.5186] |
|
|
| pe_loss = [1.1484, 0.9010, 0.8816, 0.8773, 0.9075, 0.8700, 0.8842, 0.8527, 0.8910, 0.8834, |
| 0.8639, 0.8686, 0.8485, 0.8671, 0.8575, 0.8559, 0.8891, 0.8390, 0.8585, 0.8647, |
| 0.8674, 0.8314, 0.8584, 0.8823, 0.8468, 0.8531, 0.8579, 0.8574, 0.8330, 0.8552, |
| 0.8469, 0.8647, 0.8606, 0.8558, 0.8805, 0.8528, 0.8630, 0.8740, 0.8264, 0.8690, |
| 0.8206, 0.8830, 0.8738, 0.8757, 0.8657, 0.8511, 0.8805, 0.8814, 0.8944, 0.8509, 0.8793] |
|
|
| |
| icl_loss = [0.6236, 0.5997, 0.5861, 0.5534, 0.5724, 0.5579, 0.544, 0.5841, 0.5381, 0.5378, |
| 0.511, 0.5222, 0.574, 0.4886, 0.539, 0.5127, 0.5788, 0.5257, 0.5531, 0.5653, |
| 0.531, 0.5398, 0.5831, 0.5231, 0.5727, 0.5353, 0.5425, 0.573, 0.5014, 0.505, |
| 0.5645, 0.5143, 0.529, 0.5409, 0.5585, 0.5539, 0.45, 0.4904, 0.4511, 0.414, |
| 0.4347, 0.4608, 0.4458, 0.4219, 0.4267, 0.4413, 0.4364, 0.422, 0.4207, 0.4277, 0.4263] |
|
|
| accuracy = [0.750, 0.767, 0.758, 0.782, 0.758, 0.779, 0.778, 0.753, 0.787, 0.777, |
| 0.805, 0.762, 0.689, 0.820, 0.756, 0.795, 0.749, 0.764, 0.745, 0.703, |
| 0.785, 0.763, 0.713, 0.769, 0.756, 0.765, 0.770, 0.720, 0.808, 0.790, |
| 0.733, 0.787, 0.782, 0.719, 0.781, 0.729, 0.761, 0.780, 0.771, 0.749, |
| 0.714, 0.789, 0.795, 0.800, 0.802, 0.795, 0.817, 0.805, 0.844, 0.834, 0.818] |
|
|
| |
| plt.style.use('seaborn-v0_8-whitegrid') |
| plt.rcParams.update({'font.size': 14, 'font.family': 'serif'}) |
|
|
| |
| plt.figure(figsize=(8, 6)) |
| plt.plot(epochs, laplacian_loss, 'o-', color='#1f77b4', linewidth=2.5, markersize=8) |
| plt.xlabel('Epoch') |
| plt.ylabel('Laplacian Loss') |
| plt.title('Laplacian Loss vs. Epoch') |
| plt.grid(True, linestyle='--', alpha=0.7) |
| plt.tight_layout() |
| plt.savefig('figures/laplacian_loss.png', dpi=300, bbox_inches='tight') |
| plt.close() |
|
|
| |
| plt.figure(figsize=(8, 6)) |
| plt.plot(epochs, pe_loss, 'o-', color='#ff7f0e', linewidth=2.5, markersize=8) |
| plt.xlabel('Epoch') |
| plt.ylabel('PE Loss') |
| plt.title('Positional Embedding Loss vs. Epoch') |
| plt.grid(True, linestyle='--', alpha=0.7) |
| plt.tight_layout() |
| plt.savefig('figures/pe_loss.png', dpi=300, bbox_inches='tight') |
| plt.close() |
|
|
| |
| plt.figure(figsize=(8, 6)) |
| plt.plot(epochs, icl_loss, 'o-', color='#2ca02c', linewidth=2.5, markersize=8) |
| plt.xlabel('Epoch') |
| plt.ylabel('ICL Loss') |
| plt.title('In-Context Learning Loss vs. Epoch') |
| plt.grid(True, linestyle='--', alpha=0.7) |
| plt.tight_layout() |
| plt.savefig('figures/icl_loss.png', dpi=300, bbox_inches='tight') |
| plt.close() |
|
|
| |
| plt.figure(figsize=(8, 6)) |
| plt.plot(epochs, accuracy, 'o-', color='#d62728', linewidth=2.5, markersize=8) |
| plt.xlabel('Epoch') |
| plt.ylabel('Accuracy') |
| plt.title('Classification Accuracy vs. Epoch') |
| plt.grid(True, linestyle='--', alpha=0.7) |
| plt.tight_layout() |
| plt.savefig('figures/accuracy.png', dpi=300, bbox_inches='tight') |
| plt.close() |
|
|
| |
| plt.figure(figsize=(12, 8)) |
|
|
| |
| fig, ax1 = plt.subplots(figsize=(12, 8)) |
| ax2 = ax1.twinx() |
|
|
| |
| ax1.plot(epochs, laplacian_loss, 'o-', color='#1f77b4', linewidth=2.5, markersize=6, label='Laplacian Loss') |
| ax1.plot(epochs, pe_loss, 's-', color='#ff7f0e', linewidth=2.5, markersize=6, label='PE Loss') |
| ax1.plot(epochs, icl_loss, '^-', color='#2ca02c', linewidth=2.5, markersize=6, label='ICL Loss') |
| ax1.set_xlabel('Epoch') |
| ax1.set_ylabel('Loss Value') |
| ax1.tick_params(axis='y') |
|
|
| |
| ax2.plot(epochs, accuracy, 'D-', color='#d62728', linewidth=2.5, markersize=6, label='Accuracy') |
| ax2.set_ylabel('Accuracy') |
| ax2.tick_params(axis='y') |
| ax2.set_ylim([0.65, 0.85]) |
|
|
| |
| lines1, labels1 = ax1.get_legend_handles_labels() |
| lines2, labels2 = ax2.get_legend_handles_labels() |
| ax1.legend(lines1 + lines2, labels1 + labels2, loc='center right') |
|
|
| plt.title('Training Metrics vs. Epoch') |
| plt.grid(True, linestyle='--', alpha=0.7) |
| plt.tight_layout() |
| plt.savefig('figures/combined_metrics.png', dpi=300, bbox_inches='tight') |
| plt.close() |
|
|
| print("Plots generated and saved in the 'figures' directory.") |