File size: 756 Bytes
a638e43
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
def rewrite_epoch(filename, new_file_name):
    max_value = float(-100)
    new_file = []
    
    with open(filename, 'r') as file:
        for line in file:
            new_file.append(line)
            if line.startswith("INFO:VAL"):
                anchor = float(line.split()[5]) # Assuming the value is at the 5th index
                if anchor > max_value:
                    max_value = anchor
                    print(max_value)
                    new_file.append("BEST: " + line)
    
    with open(new_file_name, 'w') as file:
        file.writelines(new_file)

# Example usage
filename = "results/tvr-top40-2024_07_11_10_58_46/20240711_105847_conquer_top40.log"
new_file_name = "new.log"
best_epoch = rewrite_epoch(filename, new_file_name)