PKU-DAIR / open-box

Generalized and Efficient Blackbox Optimization System
https://open-box.readthedocs.io
Other
376 stars 52 forks source link

injection prior knowledge to history #82

Closed rmrmg closed 7 months ago

rmrmg commented 8 months ago

according to https://open-box.readthedocs.io/en/latest/ openbox has such ability: History: Support injecting prior knowledge from previous tasks into the current search How can I do this? I couldn't find any documentation or example about it.

jhj0411jhj commented 8 months ago

Hi @rmrmg, 'history' here refers to transfer learning, please see the doc: https://open-box.readthedocs.io/en/latest/advanced_usage/transfer_learning.html

rmrmg commented 8 months ago

Thx for answer. I think I solved it and understand. For my reference and for other users (and maybe dev team will you this to improve documentation which now is rather cryptic):

  1. in openbox there is two main modes:

    • a) fully automatic where you do sth like this: Optimizer(fn, space, max_runs=850, surrogate_type='gp', task_id='q_gp4', logger_kwargs=loggerSetting)
    • b) manual, ask-and-tell, mode where you can take samples from you config space, evaluate and return back to "sampler". In this mode you have Advisor, and in simple case you do in loop:
      for itr in range(number_of_iteration_to_run):
      config = advisor.get_suggestion()
      calced_value = evaluate_function_using_params_from_config(config)
      observation = Observation(config=config, objectives=[calced_value, ])
      advisor.update_observation(observation)
  2. In ask-and-tell mode you can feed advisor with whatever you want, e.g. when you perform optimization for 100 steps with Optimizer you can get config space from previous optimizations and continue optimization, and even you can implement earlystopping mechanism by hand.

  3. To the config you can assign element as in this e.g.:

    for param in space_dict:
    config[param] = space_dict[param]
jhj0411jhj commented 7 months ago

Thanks @rmrmg! We have updated the docs for the ask-and-tell interface: https://open-box.readthedocs.io/en/latest/examples/ask_and_tell.html