Skip to content

Remove loop output transforms - #657

Open
seanmor5 wants to merge 1 commit into
mainfrom
sm-remove-output-transform
Open

Remove loop output transforms#657
seanmor5 wants to merge 1 commit into
mainfrom
sm-remove-output-transform

Conversation

@seanmor5

Copy link
Copy Markdown
Contributor

Closes #362.

Loops no longer carry an output_transform. Axon.Loop.run/4 always returns the final %Axon.Loop.State{}, so you never accidentally lose the entire training state — callers extract what they need:

%Axon.Loop.State{step_state: %{model_state: trained_model_state}} =
  Axon.Loop.run(loop, data)

Breaking changes

  • Axon.Loop.loop/3 is now Axon.Loop.loop/2 — step function plus an optional init function
  • Axon.Loop.trainer/4 no longer returns only step_state.model_state
  • Axon.Loop.evaluator/1 no longer returns only state.metrics (they're at state.metrics[epoch])

Notes

  • Axon.Loop.validate/4 was the only internal consumer of a transform; it now pattern matches %State{metrics: %{0 => validation_metrics}} off the evaluator run.
  • Tests previously worked around the trainer's default transform with Map.put(:output_transform, & &1) (plus a # TODO: Fix default output transform comment). Those are all gone.
  • The metric transform (Axon.Loop.metric/5's last argument) was also called an "output transform" in docs and error messages. That naming is now just "transform" to avoid confusion with the removed concept — the argument itself is unchanged.
  • Guides, notebooks, examples, the cheatsheet, and the README are updated to destructure the returned state. Stale cell outputs in the livemd guides were already out of date and were not regenerated.

Verification

mix test → 822 passed (198 doctests, 624 tests).

mix test --only integration fails on the same pre-existing flaky set as the unmodified baseline (verified by stashing and re-running on main): bce with simple xor model, f64 input test, image classification test, rnns static and dynamic unroll match, and the mixed-precision accuracy checks vary run to run.

🤖 Generated with Claude Code

Loops no longer carry an `output_transform`. `Axon.Loop.run/4` always
returns the final `%Axon.Loop.State{}`, so the full training state is
never silently discarded — callers extract what they need:

    %Axon.Loop.State{step_state: %{model_state: model_state}} =
      Axon.Loop.run(loop, data)

Breaking changes:

  * `Axon.Loop.loop/3` is now `Axon.Loop.loop/2`
  * `Axon.Loop.trainer/4` no longer returns only the model state
  * `Axon.Loop.evaluator/1` no longer returns only the metrics map

Closes #362

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Default loop output transforms are too intrusive

2 participants