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

What is the possible "reference" of get_standardized_data #1326

Open
beckhamwjc opened this issue Dec 21, 2021 · 2 comments
Open

What is the possible "reference" of get_standardized_data #1326

beckhamwjc opened this issue Dec 21, 2021 · 2 comments

Comments

@beckhamwjc
Copy link

Steps to reproduce

import nevergrad as ng

param = ng.p.Array(shape=(1, 10)).set_bounds(-2, 2)
optim = ng.optimzers.registry['PSO'](parametrization=param, budget=100)
x1 = optim.ask()

x1.get_standardized_data(0)
x1.get_standardized_data(1)

Observed Results

TypeError: get_standardized_data( ) takes 1 positional argument but 2 were given

Expected Results

I want to get normal output but I kept getting errors.

I've read the docs and the codes carefully but I still don't know what the "reference" is for get_standardized_data( ). What exactly am I supposed to provide get_standardized_data( ) besides "self"?

Thanks.

@StanczakDominik
Copy link

StanczakDominik commented Jan 4, 2022

Well, according to the docstring of get_standardized_data:

Parameters
----------
reference: Parameter
    the reference instance for representation in the standardized data space. This keyword parameter is
    mandatory to make the code clearer.
    If you use "self", this method will always return a zero vector.

So, with your example,

>>> x1.get_standardized_data(reference=param)
array([-1.40424398,  1.32470753, -0.73157793, -0.22966067, -1.39042444,
        1.68136875,  1.40945075, -0.78553276,  1.75506259, -1.94768554])

Hope that helps!

@jrapin
Copy link
Contributor

jrapin commented Jan 17, 2022

Exactly ;)
The reference is basically the origin of the space (param.get_standardized_data(reference=param) returns a null vector). You can use the origin that you want depending on your needs, but usually using the initial param is the simpler.

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

No branches or pull requests

3 participants