(checkpoint_dir)
| 24 | |
| 25 | |
| 26 | def get_latest_ckpt(checkpoint_dir): |
| 27 | step_dirs = [d for d in os.listdir(checkpoint_dir) if os.path.isdir(os.path.join(checkpoint_dir, d))] |
| 28 | if len(step_dirs) == 0: |
| 29 | return None |
| 30 | step_dirs = sorted(step_dirs, key=lambda x: int(x)) |
| 31 | latest_step_dir = os.path.join(checkpoint_dir, step_dirs[-1]) |
| 32 | return latest_step_dir |