smac.runner.target_function_runner¶
Classes¶
|
Class to execute target functions which are python functions. |
Interfaces¶
- class smac.runner.target_function_runner.TargetFunctionRunner(scenario, target_function, required_arguments=[])[source]¶
Bases:
AbstractSerialRunner
Class to execute target functions which are python functions. Evaluates function for given configuration and resource limit.
The target function can either return a float (the loss), or a tuple with the first element being a float and the second being additional run information. In a multi-objective setting, the float value is replaced by a list of floats.
- Parameters:
target_function (Callable) – The target function.
scenario (Scenario) –
required_arguments (list[str], defaults to []) – A list of required arguments, which are passed to the target function.
- __call__(config, algorithm, algorithm_kwargs)[source]¶
Calls the algorithm, which is processed in the
run
method.- Return type:
float
|list
[float
] |dict
[str
,float
] |tuple
[float
,dict
] |tuple
[list
[float
],dict
] |tuple
[dict
[str
,float
],dict
]
- property meta: dict[str, Any]¶
Returns the meta-data of the created object.
- run(config, instance=None, budget=None, seed=None, **dask_data_to_scatter)[source]¶
Calls the target function with pynisher if algorithm wall time limit or memory limit is set. Otherwise, the function is called directly.
- Parameters:
config (Configuration) – Configuration to be passed to the target function.
instance (str | None, defaults to None) – The Problem instance.
budget (float | None, defaults to None) – A positive, real-valued number representing an arbitrary limit to the target function handled by the target function internally.
seed (int, defaults to None) –
dask_data_to_scatter (dict[str, Any]) – This kwargs must be empty when we do not use dask! () When a user scatters data from their local process to the distributed network, this data is distributed in a round-robin fashion grouping by number of cores. Roughly speaking, we can keep this data in memory and then we do not have to (de-)serialize the data every time we would like to execute a target function with a big dataset. For example, when your target function has a big dataset shared across all the target function, this argument is very useful.
- Return type:
tuple
[StatusType
,float
|list
[float
],float
,dict
]- Returns:
status (StatusType) – Status of the trial.
cost (float | list[float]) – Resulting cost(s) of the trial.
runtime (float) – The time the target function took to run.
additional_info (dict) – All further additional trial information.