jina.optimizers.parameters module

class jina.optimizers.parameters.OptimizationParameter(parameter_name='', executor_name=None, prefix='JINA', jaml_variable=None)[source]

Bases: jina.jaml.JAMLCompatible

Base class for all optimization parameters.

update_trial_params(trial, trial_params)[source]

Update the trial parameters given the variables and the trials

Parameters
  • trial (Trial) – An instance of an Optuna Trial object

  • trial_params (Dict) – the parameters to update # noqa: DAR201

class jina.optimizers.parameters.IntegerParameter(low, high, step_size=1, log=False, *args, **kwargs)[source]

Bases: jina.optimizers.parameters.OptimizationParameter

Used for optimizing integer parameters with the FlowOptimizer. For detailed information about sampling and usage see https://optuna.readthedocs.io/en/stable/reference/generated/optuna.trial.Trial.html#optuna.trial.Trial.suggest_int

class jina.optimizers.parameters.UniformParameter(low, high, *args, **kwargs)[source]

Bases: jina.optimizers.parameters.OptimizationParameter

Used for optimizing float parameters with the FlowOptimizer with uniform sampling. For detailed information about sampling and usage see https://optuna.readthedocs.io/en/stable/reference/generated/optuna.trial.Trial.html#optuna.trial.Trial.suggest_discrete_uniform

class jina.optimizers.parameters.LogUniformParameter(low, high, *args, **kwargs)[source]

Bases: jina.optimizers.parameters.OptimizationParameter

Used for optimizing float parameters with the FlowOptimizer with loguniform sampling. For detailed information about sampling and usage see https://optuna.readthedocs.io/en/stable/reference/generated/optuna.trial.Trial.html#optuna.trial.Trial.suggest_loguniform

class jina.optimizers.parameters.CategoricalParameter(choices, *args, **kwargs)[source]

Bases: jina.optimizers.parameters.OptimizationParameter

Used for optimizing categorical parameters with the FlowOptimizer. For detailed information about sampling and usage see https://optuna.readthedocs.io/en/stable/reference/generated/optuna.trial.Trial.html#optuna.trial.Trial.suggest_categorical

class jina.optimizers.parameters.DiscreteUniformParameter(low, high, q, *args, **kwargs)[source]

Bases: jina.optimizers.parameters.OptimizationParameter

Used for optimizing discrete parameters with the FlowOptimizer with uniform sampling. For detailed information about sampling and usage it is used by Jina with optuna see https://optuna.readthedocs.io/en/stable/reference/generated/optuna.trial.Trial.html#optuna.trial.Trial.suggest_discrete_uniform

class jina.optimizers.parameters.ExecutorAlternativeParameter(inner_parameters, *args, **kwargs)[source]

Bases: jina.optimizers.parameters.CategoricalParameter

Used for optimizing alternative executor parameters. It selects from choices the same way as :class::CategoricalParameter does. Plus adds some inner parameters that expose different OptimizationParameters for each of the specific options.

choices = ['executorA', 'executorB']
inner_parameters = {
        'executorA': [IntegerParameter(..., parameter_name='executorA_param1'),
            CategoricalParameter(..., parameter_name='executorA_param2')],
        'executorB': [IntegerParameter(..., parameter_name='executorB_param1'),
            CategoricalParameter(..., parameter_name='executorB_param2')]
        }

parameter = ExecutorAlternativeParameter(choices=choices, inner_parameters=inner_parameters)
update_trial_params(trial, trial_params)[source]

Update the trial parameters given the variables and the trials

Parameters
  • trial (Trial) – An instance of an Optuna Trial object

  • trial_params (Dict) – the parameters to update # noqa: DAR201

jina.optimizers.parameters.load_optimization_parameters(filepath)[source]

Loads optimization parameters from a .yml file and parses it with the JAML parser. :type filepath: str :param filepath: Path to a file that contains optimization parameters. :return:: The loaded OptimizationParameter objects.