Skip to content

Commit

Permalink
Address Shawn CR
Browse files Browse the repository at this point in the history
Add logging and documentation to clarify behaviour of specifying max_num_validation_steps
  • Loading branch information
jewelltaylor committed Dec 18, 2024
1 parent 9da8ff1 commit 68ca106
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions fl4health/clients/basic_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ def __init__(
self.learning_rate: Optional[float] = None
# Config can contain max_num_validation_steps key, which determines an upper bound
# for the validation steps taken. If not specified, no upper bound will be enforced.
# By specifying this in the config we cannot guarantee the validation set is the same
# accross rounds for clients.
self.max_num_validation_steps: int | None = None

def _maybe_checkpoint(self, loss: float, metrics: dict[str, Scalar], checkpoint_mode: CheckpointMode) -> None:
Expand Down Expand Up @@ -839,6 +841,14 @@ def setup_client(self, config: Config) -> None:
self.test_loader = self.get_test_data_loader(config)

if "max_num_validation_steps" in config:
log(
INFO,
"""
max_num_validation_steps specified in config. Only a random subset of batches will \
be sampled from the validation set if max_num_validation_steps is greater \
than the number of batches in the validation dataloader.
""",
)
self.max_num_validation_steps = narrow_dict_type(config, "max_num_validation_steps", int)
else:
self.max_num_validation_steps = None
Expand Down

0 comments on commit 68ca106

Please sign in to comment.