From 0323d3a4854956e55f68e54f64a7f5085d8b8b02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20de=20Kok?= Date: Tue, 23 Apr 2024 09:20:16 +0200 Subject: [PATCH] Document the `Optimizer.last_score` property (#934) * Document the `Optimizer.last_score` property * Grammar fix Co-authored-by: Sofie Van Landeghem * Prettier --------- Co-authored-by: Sofie Van Landeghem --- website/docs/api-optimizers.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/website/docs/api-optimizers.md b/website/docs/api-optimizers.md index 2deab184e..2055caa7d 100644 --- a/website/docs/api-optimizers.md +++ b/website/docs/api-optimizers.md @@ -207,6 +207,25 @@ and parameter name. | _keyword-only_ | | | | `lr_scale` | float | Rescale the learning rate. Defaults to `1.0`. | +### Optimizer.last_score {#last_score tag="property", new="9"} + +Get or set the last evaluation score. The optimizer passes this score to the +learning rate schedule, so that the schedule can take training dynamics into +account (see e.g. the [`plateau`](/docs/api-schedules#plateau) schedule). + +```python +### Example +from thinc.api import Optimizer, constant, plateau + +schedule = plateau(2, 0.5, constant(1.0)) +optimizer = Optimizer(learn_rate=schedule) +optimizer.last_score = (1000, 88.34) +``` + +| Argument | Type | Description | +| ----------- | ------------------------------------ | ------------------------------------------ | +| **RETURNS** | Optional[Tuple[int, float]] | The step and score of the last evaluation. | + ### Optimizer.step_schedules {#step_schedules tag="method"} Increase the current step of the optimizer. This step will be used by schedules