4dgs-dpm / gs /utils /plot_loss_log.py
dxm21's picture
Upload folder using huggingface_hub
8c48cce verified
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"""
# Load loss values from txt file
with open(loss_file, 'r') as f:
losses = [float(line.strip()) for line in f if line.strip()]
# Create figure with log scale
plt.figure(figsize=(12, 6))
plt.semilogy(losses, label='Training Loss')
# Customize plot
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()
# Save plot
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()