orbit.actions.ExportFileManager
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
Utility class that manages a group of files with a shared base name.
orbit.actions.ExportFileManager(
base_name: str,
max_to_keep: int = 5,
next_id_fn: Optional[Callable[[], int]] = None,
subdirectory: Optional[str] = None
)
For actions like SavedModel exporting, there are potentially many different
file naming and cleanup strategies that may be desirable. This class provides
a basic interface allowing SavedModel export to be decoupled from these
details, and a default implementation that should work for many basic
scenarios. Users may subclass this class to alter behavior and define more
customized naming and cleanup strategies.
Args |
base_name
|
A shared base name for file names generated by this class.
|
max_to_keep
|
The maximum number of files matching base_name to keep
after each call to cleanup. The most recent (as determined by file
modification time) max_to_keep files are preserved; the rest are
deleted. If < 0, all files are preserved.
|
next_id_fn
|
An optional callable that returns integer IDs to append to
base name (formatted as '{base_name}-{id}'). The order of integers is
used to sort files to determine the oldest ones deleted by clean_up.
If not supplied, a default ID based on an incrementing counter is used.
One common alternative maybe be to use the current global step count,
for instance passing next_id_fn=global_step.numpy.
|
subdirectory
|
An optional subdirectory to concat after the
{base_name}-{id}. Then the file manager will manage
{base_name}-{id}/{subdirectory} files.
|
Attributes |
managed_files
|
Returns all files managed by this instance, in sorted order.
|
Methods
clean_up
View source
clean_up()
Cleans up old files matching {base_name}-*.
The most recent max_to_keep files are preserved.
next_name
View source
next_name() -> str
Returns a new file name based on base_name and next_id_fn().
如未另行说明,则本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。如需了解详情,请参阅 Google Developers 网站政策。Java 是 Oracle 和/或其关联公司的注册商标。某些内容已根据 Numpy 许可获得了许可。
最后更新时间 (UTC):2026-02-13。
[null,null,["最后更新时间 (UTC):2026-02-13。"],[],[]]