Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

record max step and min step #341

Merged
merged 1 commit into from
Feb 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions swanlab/data/run/exp.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,12 @@ def add(self, data: DataType, step: int = None):
is_nan = self.__is_nan(data)
if not is_nan:
# 如果数据比之前的数据小,则更新最小值,否则不更新
self._summary["max"] = data if self._summary.get("max") is None else max(self._summary["max"], data)
self._summary["min"] = data if self._summary.get("min") is None else min(self._summary["min"], data)
if self._summary.get("max") is None or data > self._summary["max"]:
self._summary["max"] = data
self._summary["max_step"] = step
if self._summary.get("min") is None or data < self._summary["min"]:
self._summary["min"] = data
self._summary["min_step"] = step
self._summary["num"] = self._summary.get("num", 0) + 1
self.__steps.add(step)
swanlog.debug(f"Add data, tag: {self.tag}, step: {step}, data: {data}")
Expand Down