Deletes old checkpoints if necessary. `self._checkpoints_to_be_deleted` is going to contain checkpoints that are over `max_to_keep`. They are going to be deleted. If `keep_checkpoint_every_n_hours` was specified, keep an additional checkpoint every `N` hours. For example, if `N` i
(self, meta_graph_suffix="meta")
| 1196 | self._checkpoints_to_be_deleted.append(self._last_checkpoints.pop(0)) |
| 1197 | |
| 1198 | def _MaybeDeleteOldCheckpoints(self, meta_graph_suffix="meta"): |
| 1199 | """Deletes old checkpoints if necessary. |
| 1200 | |
| 1201 | `self._checkpoints_to_be_deleted` is going to contain checkpoints that are |
| 1202 | over `max_to_keep`. They are going to be deleted. If |
| 1203 | `keep_checkpoint_every_n_hours` was specified, keep an additional checkpoint |
| 1204 | every `N` hours. For example, if `N` is 0.5, an additional checkpoint is |
| 1205 | kept for every 0.5 hours of training; if `N` is 10, an additional |
| 1206 | checkpoint is kept for every 10 hours of training. |
| 1207 | |
| 1208 | Args: |
| 1209 | meta_graph_suffix: Suffix for `MetaGraphDef` file. Defaults to 'meta'. |
| 1210 | """ |
| 1211 | if self._checkpoints_to_be_deleted: |
| 1212 | p = self._checkpoints_to_be_deleted.pop(0) |
| 1213 | # Do not delete the file if we keep_checkpoint_every_n_hours is set and we |
| 1214 | # have reached N hours of training. |
| 1215 | should_keep = p[1] > self._next_checkpoint_time |
| 1216 | if should_keep: |
| 1217 | self._next_checkpoint_time += ( |
| 1218 | self.saver_def.keep_checkpoint_every_n_hours * 3600) |
| 1219 | return |
| 1220 | |
| 1221 | # Otherwise delete the files. |
| 1222 | try: |
| 1223 | checkpoint_management.remove_checkpoint( |
| 1224 | self._CheckpointFilename(p), self.saver_def.version, |
| 1225 | meta_graph_suffix) |
| 1226 | except Exception as e: # pylint: disable=broad-except |
| 1227 | logging.warning("Ignoring: %s", str(e)) |
| 1228 | |
| 1229 | def as_saver_def(self): |
| 1230 | """Generates a `SaverDef` representation of this saver. |
no test coverage detected