Fix auto-optimisation direction for Bactrian scale factor (#96)#97
Merged
Conversation
AbstractScale.optimize() used the legacy ScaleOperator transform, which assumes scaleFactor close to 0 means large jumps. The Bactrian kernel has the opposite relationship (scale = exp(scaleFactor * N(0,1)), so larger scaleFactor means larger jumps), making auto-optimisation run backwards for operators that inherit the base method (e.g. ScaleTreeOperator): low acceptance increased the scale factor instead of decreasing it, and the transform went NaN for scaleFactor >= 1. Tune multiplicatively in the kernel direction (sf *= exp(delta)), matching the form already used by the ScaleOperator and IntervalScaleOperator overrides. The redundant override in ScaleOperator is removed, and the scaleFactor input description is corrected. Fixes #96
Member
|
This looks good to me. I am surprised this was unnoticed for so long |
Default the upper limit to 10.0 directly in AbstractScale and IntervalScaleOperator, and remove the brittle initAndValidate hack that bumped the legacy 1-1e-8 default to 10.0 via a floating-point equality check (which also silently overrode a deliberate user value). Correct the IntervalScaleOperator scaleFactor description to match the Bactrian semantics.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #96.
The spec scale operators draw from a Bactrian kernel (
scale = exp(scaleFactor * N(0,1))), so largerscaleFactormeans larger jumps / lower acceptance — the opposite of the legacyScaleOperator.Changes
AbstractScale.optimize()tunes multiplicatively in the kernel direction (sf *= exp(delta)): acceptance too high increases the scale factor, too low decreases it. The old legacy transform ran the optimiser backwards and wentNaNforscaleFactor >= 1.10.0directly inAbstractScaleandIntervalScaleOperator, giving the optimiser the headroom it needs above 1. This removes the brittleinitAndValidatehack that bumped the legacy1 - 1e-8default to10.0via a floating-point equality check (which also silently overrode a deliberate user value).optimize()override inScaleOperator.scaleFactorinput descriptions, which documented the inverted legacy semantics.IntervalScaleOperatorextendsTreeOperator(separate hierarchy); itsoptimize()already tuned in the correct direction but its upper limit was still capped at ~1.0, so it is fixed here too.Testing
mvn -pl beast-base compilesucceeds.