| import numpy as np |
| import matplotlib.pyplot as plt |
|
|
| def plot_loss_log(loss_file="output/steak/loss.txt"): |
| """Plot training loss values on a logarithmic scale from loss.txt""" |
| |
| |
| with open(loss_file, 'r') as f: |
| losses = [float(line.strip()) for line in f if line.strip()] |
| |
| |
| plt.figure(figsize=(12, 6)) |
| plt.semilogy(losses, label='Training Loss') |
| |
| |
| plt.grid(True, which="both", ls="-", alpha=0.2) |
| plt.xlabel('Iteration') |
| plt.ylabel('Loss (log scale)') |
| plt.title('Training Loss over Time (Log Scale)') |
| plt.legend() |
| |
| |
| output_path = loss_file.replace('.txt', '_plot_log.png') |
| plt.savefig(output_path, dpi=300, bbox_inches='tight') |
| plt.close() |
| |
| print(f"Saved loss plot to: {output_path}") |
| print(f"Loss statistics:") |
| print(f" Min: {min(losses):.6f}") |
| print(f" Max: {max(losses):.6f}") |
| print(f" Mean: {np.mean(losses):.6f}") |
| print(f" Final: {losses[-1]:.6f}") |
|
|
| if __name__ == "__main__": |
| plot_loss_log() |