Skip to content

feat(perturbations): rename sigma→scale, default num_samples=1 (#1342)#1662

Open
yurekami wants to merge 2 commits into
google-deepmind:mainfrom
yurekami:refine-make-perturbed-fun
Open

feat(perturbations): rename sigma→scale, default num_samples=1 (#1342)#1662
yurekami wants to merge 2 commits into
google-deepmind:mainfrom
yurekami:refine-make-perturbed-fun

Conversation

@yurekami

Copy link
Copy Markdown

Closes #1342.

Implements the two refinements maintainers pre-approved on the issue:

  1. Rename sigmascale in optax.perturbations.make_perturbed_fun. scale is the more generic/self-explanatory name suggested in the issue. The old sigma kwarg is preserved as a keyword-only deprecated alias that emits a DeprecationWarning — existing positional callers are unaffected.
  2. Default num_samples 1000 → 1, matching the convention common in stochastic optimization (where the objective is itself stochastic).

Changes

  • optax/perturbations/_make_pert.py — signature, docstring, deprecation shim
  • optax/perturbations/_make_pert_test.py — update kwarg calls; add test_sigma_deprecation and test_default_num_samples
  • examples/perturbations.ipynb — update 3 call sites from sigma=SIGMA to scale=SIGMA

Test plan

  • pytest optax/perturbations/_make_pert_test.py — 19/19 pass locally
  • ruff check — clean
  • CI green on all matrix jobs

… to 1

Implements the two refinements proposed in google-deepmind#1342:

- Rename `make_perturbed_fun`'s `sigma` parameter to `scale`, the more
  generic name suggested in the issue. The old `sigma` kwarg is kept as
  a keyword-only deprecated alias that emits a `DeprecationWarning`;
  positional callers are unaffected.
- Change the default value of `num_samples` from 1000 to 1, matching
  the convention common in stochastic optimization.

Updates tests (adds test_sigma_deprecation and test_default_num_samples),
the perturbations example notebook, and the docstring.
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.

Minor suggestions for make_perturbed_fun

1 participant