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

Simplify sampling with bounds #1071

Open
jrapin opened this issue Mar 9, 2021 · 2 comments
Open

Simplify sampling with bounds #1071

jrapin opened this issue Mar 9, 2021 · 2 comments

Comments

@jrapin
Copy link
Contributor

jrapin commented Mar 9, 2021

Context

Standardized space is an unbounded Rn space. Many algorithms however work on bounded domains, so that we usually use a arctan-based transform from [0,1] to R, and the other way round. However, if the actual work space is actually bounded, this can transform space in weird ways.

Need

We need a standard way to convert from [0,1] to the actual domain, be it bounded or unbounded. This is currently done by the BoundScaler

class BoundScaler:
"""Hacky way to sample in the space defined by the parametrization.
Given an vector of values between 0 and 1,
the transform method samples in the bounds if provided,
or using the provided function otherwise.
This is used for samplers.
Code of parametrization and/or this helper should definitely be
updated to make it simpler and more robust
"""

It is currently used by one-shot optimizers. This should be made more robust and more general, with both forward and backward transform to the state domain, so as to be included in other algorithms such as BO (in BO the backward transform is necessary for the tell-not-asked).

This work my require enforcing some prior on the ordering of the data in Parameter containers, and is related to:

def split_as_data_parameters(
parameter: core.Parameter,
) -> tp.List[tp.Tuple[str, pdata.Data]]:
"""List all the instances involved as parameter (not as subparameter/
endogeneous parameter)
Parameter
---------
parameter: Parameter
the parameter to split
Returns
-------
list
the list and subparameters ordered as in data space
Note
----
This function is experimental, its output will probably evolve before converging.
"""

which should be simplified as well.

@jrapin
Copy link
Contributor Author

jrapin commented Mar 9, 2021

Related problem:
Middle point for one-shots does not go through the scaler:

if self.middle_point and not self._num_ask:
return np.zeros(self.dimension)

@beckhamwjc
Copy link

Is it possible to do gaussian sampling with, for example, a ng.p.Array(shape=(n,)) in actually R^n space? This is important because there is often NO reason to restrict the boundaries of parameters to be optimized in reality, and gaussian sampling is obviously more efficient than uniform sampling which I assume is the current sampling method that Nevergrad adopted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants