Local search¶
-
cgp.local_search.
gradient_based
(individual: cgp.individual.IndividualBase, objective: Callable[[Union[torch.nn.Module, List[torch.nn.Module]]], torch.Tensor], lr: float, gradient_steps: int, optimizer: Optional[Optimizer] = None, clip_value: Optional[float] = None) → None[source]¶ Perform a local search for numeric leaf values for an individual based on gradient information obtained via automatic differentiation.
- individualIndividual
Individual for which to perform local search.
- objectiveCallable
Objective function that is called with a differentiable graph and returns a differentiable loss.
- lrfloat
Learning rate for optimizer.
- gradient_stepsint
Number of gradient steps per individual.
- optimizertorch.optim.Optimizer, optional
Optimizer to use for parameter updates. Defaults to torch.optim.SGD.
- clip_valuefloat, optional
Clipping value for gradients. Clipping is skipped when set to np.inf. Defaults to 10% of the inverse of the learning rate so that the maximal update step is 0.1.