Skip to content

put the monitor metric into default filename for ModelCheckpoint #20397

Open
@VDFaller

Description

@VDFaller

Description & Motivation

Tiny annoyance, but wouldn't it make sense to put the monitor value in the default value of the filename so it's not just epoch-X-step-y by default?

Pitch

Couldn't something like this work here?

    def _format_checkpoint_name(
        self,
        filename: Optional[str],
        metrics: Dict[str, Tensor],
        prefix: str = "",
        auto_insert_metric_name: bool = True,
    ) -> str:
        if not filename:
            if self.monitor is not None and self.monitor in metrics:
                filename = "{epoch}" + self.CHECKPOINT_JOIN_CHAR + "{step}" + self.CHECKPOINT_JOIN_CHAR + f"{{{self.monitor}}}"
            # filename is not set, use default name
            else:
                filename = "{epoch}" + self.CHECKPOINT_JOIN_CHAR + "{step}"

Alternatives

No response

Additional context

Happy to put it in MR

cc @Borda

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureIs an improvement or enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions