EmuKit / emukit

A Python-based toolbox of various methods in decision making, uncertainty quantification and statistical emulation: multi-fidelity, experimental design, Bayesian optimisation, Bayesian quadrature, etc.
https://emukit.github.io/emukit/
Apache License 2.0
605 stars 128 forks source link

Question: extra outputs is not compatible with context manager with multiple context variables? #312

Open clairecp opened 4 years ago

clairecp commented 4 years ago

Hello everyone!

When using extra_outputs from the user_function, I was expecting extra_outputs to be directly usable as context? However in emukit.core.loop.user_function.py, the extra outputs have to be np.ndarrays of at least 2d and so the dictionary of extra_outputs that is returned is of the form {'key0': array([2.1]), 'key1': array([2.]), 'key2': array([1.])}.

By using this dictionary as context, when multiple context values are present, the expend_vector method in core.optimization.context_manager.py fails with a broadcast error because the context_values is no longer 1d.

This is not really an issue, as we can simply process the extra_outputs after getting them from the user_function_result to make them simple values instead of arrays. But I wanted to ask if the requirements for extra_outputs to be 2d numpy arrays is due to some functionality I am missing? I was expecting the extra_outputs to be directly compatible with context_manager when used as context?

Looking forward to your answer, Thanks!

mmahsereci commented 4 years ago

hi @ClaireCp , could you perhaps supply a code sniped that shows where the code fails? It would be easier for me to understand precisely what you are referring. Thanks!