MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / _get_file_path

Method _get_file_path

tensorflow/python/keras/callbacks.py:1019–1034  ·  view source on GitHub ↗

Returns the file path for checkpoint.

(self, epoch, logs)

Source from the content-addressed store, hash-verified

1017 self._maybe_remove_file()
1018
1019 def _get_file_path(self, epoch, logs):
1020 """Returns the file path for checkpoint."""
1021 # pylint: disable=protected-access
1022 if not self.model._in_multi_worker_mode(
1023 ) or multi_worker_util.should_save_checkpoint():
1024 return self.filepath.format(epoch=epoch + 1, **logs)
1025 else:
1026 # If this is multi-worker training, and this worker should not
1027 # save checkpoint, we use a temp filepath to store a dummy checkpoint, so
1028 # it writes to a file that will be removed at the end of `_save_model()`
1029 # call. This is because the SyncOnReadVariable needs to be synced across
1030 # all the workers in order to be read, and all workers need to initiate
1031 # that.
1032 self._temp_file_dir = tempfile.mkdtemp()
1033 extension = os.path.splitext(self.filepath)[1]
1034 return os.path.join(self._temp_file_dir, 'temp' + extension)
1035
1036 def _maybe_remove_file(self):
1037 # Remove the checkpoint directory in multi-worker training where this worker

Callers 1

_save_modelMethod · 0.95

Calls 4

mkdtempMethod · 0.80
_in_multi_worker_modeMethod · 0.45
formatMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected