Index
|
A class for applying and updating \(\phi\). |
|
A class for applying and updating \(\phi\). |
API
- class FOX.armc.PhiUpdaterABC(phi, gamma, a_target, func, **kwargs)[source]
A class for applying and updating \(\phi\).
Has two main methods:
Examples
>>> import numpy as np >>> value = np.ndarray(...) >>> phi = PhiUpdater(...) >>> phi(value) >>> phi.update(...)
- phi
The variable \(\phi\).
- gamma
The constant \(\gamma\).
- a_target
The target acceptance rate \(\alpha_{t}\).
- func
The callable used for applying \(\phi\) to the auxiliary error. The callable should take an array-like object and a
numpy.ndarray
as arguments and return a new array.
- property shape
-
Serves as a wrapper around the
shape
attribute ofphi
. Note thatphi
,gamma
anda_target
all have the same shape.
- abstract update(acceptance, **kwargs)[source]
An abstract method for updating
phi
based on the values ofgamma
and acceptance.- Parameters
acceptance (ArrayLike[np.bool_]) – An array-like object consisting of booleans.
**kwargs (
Any
) – Further keyword arguments which can be customized in the methods of subclasses.
- class FOX.armc.PhiUpdater(phi=1.0, gamma=2.0, a_target=0.25, func=<ufunc 'add'>, **kwargs)[source]
A class for applying and updating \(\phi\).
Has two main methods:
Examples
>>> import numpy as np >>> value = np.ndarray(...) >>> phi = PhiUpdater(...) >>> phi(value) >>> phi.update(...)
- phi
The variable \(\phi\).
- gamma
The constant \(\gamma\).
- a_target
The target acceptance rate \(\alpha_{t}\).
- func
The callable used for applying \(\phi\) to the auxiliary error. The callable should take an array-like object and a
numpy.ndarray
as arguments and return a new array.
- update(acceptance, *, logger=None)[source]
Update the variable \(\phi\).
\(\phi\) is updated based on the target accepatance rate, \(\alpha_{t}\), and the acceptance rate, acceptance, of the current super-iteration:
\[\phi_{\kappa \omega} = \phi_{ ( \kappa - 1 ) \omega} * \gamma^{ \text{sgn} ( \alpha_{t} - \overline{\alpha}_{ ( \kappa - 1 ) }) }\]- Parameters
acceptance (ArrayLike[np.bool_]) – An array-like object consisting of booleans.
logger (
logging.Logger
, optional) – A logger for reporting the updated value.