Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GD raises deprecation warning if atol and rtol are not used #2054

Closed
hrobarts opened this issue Jan 29, 2025 · 0 comments · Fixed by #2056
Closed

GD raises deprecation warning if atol and rtol are not used #2054

hrobarts opened this issue Jan 29, 2025 · 0 comments · Fixed by #2056
Assignees
Labels
bug Something isn't working

Comments

@hrobarts
Copy link
Contributor

hrobarts commented Jan 29, 2025

Description

GD raises a deprecation warning if atol or rtol are passed and are !=0. But the default value if they're not passed is None so the deprecation warning is also raised if the arguments are not used at all.

self.rtol = kwargs.pop('rtol', None) # to be deprecated (released in 25.0)
self.atol = kwargs.pop('atol', None) # to be deprecated (released in 25.0)
if kwargs.get('objective_function') is not None: # to be deprecated
warn('The argument `objective_function` will be deprecated in the future. Please use `f` instead.', DeprecationWarning, stacklevel=2)
if f is not None:
raise ValueError('The argument `objective_function` is being deprecated, replaced by `f`. Please use just `f` not both')
f = kwargs.pop('objective_function')
if self.alpha is not None or self.beta is not None: # to be deprecated
warn('To modify the parameters for the Armijo rule please use `step_size_rule=ArmijoStepSizeRule(alpha, beta, kmax)`. The arguments `alpha` and `beta` will be deprecated. ', DeprecationWarning, stacklevel=2)
if self.rtol!=0 or self.atol!=0: # to be deprecated (released in 25.0)
warn('`rtol` and `atol` are deprecated. For early stopping, please use a callback (cil.optimisation.utilities.callbacks), for example `EarlyStoppingObjectiveValue`.', DeprecationWarning, stacklevel=2)
else:
log.warn('Breaking backwards compatibility, GD no longer automatically stops if the objective function is close to zero. For this functionality, please use a callback (cil.optimisation.utilities.callbacks).' )

myGD_LS = GD(initial=x0, 
             f=f1, 
             step_size=None,
             update_objective_interval=10)

DeprecationWarning: `rtol` and `atol` are deprecated. For early stopping, please use a callback (cil.optimisation.utilities.callbacks),  for example `EarlyStoppingObjectiveValue`.
  myGD_LS = GD(initial=x0,

Environment

import cil, sys
print(cil.version.version, cil.version.commit_hash, sys.version, sys.platform)

24.3.0 None 3.12.8 | packaged by conda-forge | (main, Dec 5 2024, 14:24:40) [GCC 13.3.0] linux

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant