Download code/fix_global_step.py from unknownBrain/survivalanalysis_checkpointing: direct link, hf CLI and curl.
- Browser
- Download file 562 Bytes
-
https://huggingface.co/datasets/unknownBrain/survivalanalysis_checkpointing/resolve/main/code/fix_global_step.py
- Command line
-
hf download hf://datasets/unknownBrain/survivalanalysis_checkpointing/code/fix_global_step.py
-
curl -L -o fix_global_step.py https://huggingface.co/datasets/unknownBrain/survivalanalysis_checkpointing/resolve/main/code/fix_global_step.py
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") | |