File size: 1,318 Bytes
6ac44e1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import os
import argparse
import pandas as pd
import matplotlib.pyplot as plt

def plot_evaluation_loss(exp_dir, epoch):
   
    # Build paths
    log_dir = os.path.join(exp_dir, 'log')
    eval_pkl = os.path.join(log_dir, f'eval_loss_epoch_{epoch}.pkl')
    if not os.path.isfile(eval_pkl):
        raise FileNotFoundError(f"Evaluation pickle not found: {eval_pkl}")

    # Load data
    df = pd.read_pickle(eval_pkl)
    eval_losses = df['epoch_eval_losses']
    epochs = list(range(1, len(eval_losses) * 20, 20))

    # Plot
    plt.figure(figsize=(10, 5))
    plt.plot(epochs, eval_losses, marker='o', linestyle='-', linewidth=1.5, markersize=5)
    plt.xlabel('Epoch')
    plt.ylabel('Evaluation Loss')
    plt.title(f'Evaluation Loss (epoch {epoch})')
    plt.grid(True)

    # Save
    save_dir = os.path.join(exp_dir, 'plots')
    os.makedirs(save_dir, exist_ok=True)
    out_path = os.path.join(save_dir, f'eval_loss_epoch_{epoch}.png')
    plt.tight_layout()
    plt.savefig(out_path)
    plt.close()
    print(f"Saved evaluation plot to {out_path}")

def main():
    exp_dir = '/home/bipinshrestha228/GlassForming/new_data_12/original/k_120/Fri-Jun-27-18-00-56-2025'
    epoch = 460
    plot_evaluation_loss(exp_dir, epoch)
    
if __name__ == '__main__':
    main()