CONQUER_RVMR / unused /find_best_epoch.py
Liangrj5
init
a638e43
raw
history blame contribute delete
756 Bytes
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)