Iterate all checkpoints in model directory in order they are created.
(model_dir)
| 188 | |
| 189 | |
| 190 | def checkpoints_iterator(model_dir): |
| 191 | """Iterate all checkpoints in model directory in order they are created.""" |
| 192 | visited = set() |
| 193 | while True: |
| 194 | tf.logging.info("Waiting for new checkpoints at %s", model_dir) |
| 195 | while True: |
| 196 | ckpt_state = tf.train.get_checkpoint_state(model_dir) |
| 197 | if not ckpt_state: |
| 198 | time.sleep(1) |
| 199 | continue |
| 200 | ckpt_paths = ckpt_state.all_model_checkpoint_paths |
| 201 | new_ckpts = [p for p in ckpt_paths if p not in visited] |
| 202 | if new_ckpts: |
| 203 | break |
| 204 | new_ckpts = sorted( |
| 205 | new_ckpts, key=lambda x: int(os.path.basename(x).split("-")[1])) |
| 206 | tf.logging.info("Found new checkpoint at %s", new_ckpts[0]) |
| 207 | yield new_ckpts[0] |
| 208 | visited.add(new_ckpts[0]) |
| 209 | |
| 210 | |
| 211 | def evaluate_checkpoints( |
no test coverage detected
searching dependent graphs…