survivalanalysis_checkpointing / code /fix_global_step.py
unknownBrain's picture
Upload all remaining preprocessing, standalone, test and utility files
ee594f0 verified
Raw History Blame Contribute Delete
562 Bytes
import re
with open('Train_CMTLNet_Step2.py', 'r') as f:
code = f.read()
target = """ scaler.step(optimizer)
scaler.update()
# Get current learning rate"""
replacement = """ scaler.step(optimizer)
scaler.update()
global_step += 1
# Get current learning rate"""
if target in code:
code = code.replace(target, replacement)
with open('Train_CMTLNet_Step2.py', 'w') as f:
f.write(code)
print("Fixed global_step")
else:
print("Target not found")