Optimizers
Optimizers (like Adam or ClipUp) to be used with distribution-based search algorithms.
Adam
¶
Bases: TorchOptimizer
The Adam optimizer.
Reference:
Kingma, D. P. and J. Ba (2015).
Adam: A method for stochastic optimization.
In Proceedings of 3rd International Conference on Learning Representations.
Source code in evotorch/optimizers.py
__init__(*, solution_length, dtype, device='cpu', stepsize=None, beta1=None, beta2=None, epsilon=None, amsgrad=None)
¶
__init__(...)
: Initialize the Adam optimizer.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
solution_length
|
int
|
Length of a solution of the problem which is being worked on. |
required |
dtype
|
DType
|
The dtype of the problem which is being worked on. |
required |
device
|
Device
|
The device on which the solutions are kept. |
'cpu'
|
stepsize
|
Optional[float]
|
The step size (i.e. the learning rate) employed by the optimizer. |
None
|
beta1
|
Optional[float]
|
The beta1 hyperparameter. None means the default. |
None
|
beta2
|
Optional[float]
|
The beta2 hyperparameter. None means the default. |
None
|
epsilon
|
Optional[float]
|
The epsilon hyperparameters. None means the default. |
None
|
amsgrad
|
Optional[bool]
|
Whether or not to use the amsgrad behavior.
None means the default behavior.
See |
None
|
Source code in evotorch/optimizers.py
ClipUp
¶
The ClipUp optimizer.
Reference:
Toklu, N. E., Liskowski, P., & Srivastava, R. K. (2020, September).
ClipUp: A Simple and Powerful Optimizer for Distribution-Based Policy Evolution.
In International Conference on Parallel Problem Solving from Nature (pp. 515-527).
Springer, Cham.
Source code in evotorch/optimizers.py
231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 |
|
contained_optimizer
property
¶
Get this ClipUp
instance itself.
param_groups
property
¶
Returns a single-element tuple representing a parameter group.
The tuple contains a dictionary-like object in which the keys are the
hyperparameter names, and the values are the values of those
hyperparameters. The hyperparameter names are lr
(the step size, or
the learning rate), max_speed
(the maximum speed), and momentum
(the momentum coefficient). The values of these hyperparameters can be
read and also be written if one wishes to adjust the behavior of ClipUp
during the optimization.
__init__(*, solution_length, dtype, stepsize, momentum=0.9, max_speed=None, device='cpu')
¶
__init__(...)
: Initialize the ClipUp optimizer.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
solution_length
|
int
|
Length of a solution of the problem which is being worked on. |
required |
dtype
|
DType
|
The dtype of the problem which is being worked on. |
required |
stepsize
|
float
|
The step size (i.e. the learning rate) employed by the optimizer. |
required |
momentum
|
float
|
The momentum coefficient. None means the default. |
0.9
|
max_speed
|
Optional[float]
|
The maximum speed. If given as None, the
|
None
|
device
|
Device
|
The device on which the solutions are kept. |
'cpu'
|
Source code in evotorch/optimizers.py
ascent(globalg, *, cloned_result=True)
¶
Compute the ascent, i.e. the step to follow.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
globalg
|
RealOrVector
|
The estimated gradient. |
required |
cloned_result
|
bool
|
If |
True
|
Source code in evotorch/optimizers.py
ClipUpParameterGroup
¶
Bases: Mapping
A dictionary-like object storing the hyperparameters of a ClipUp instance.
The values of the hyperparameters within this container can be read and can also be written if one wishes to adjust the behavior of ClipUp during the optimization.
Source code in evotorch/optimizers.py
SGD
¶
Bases: TorchOptimizer
The SGD optimizer.
Reference regarding the momentum behavior:
Polyak, B. T. (1964).
Some methods of speeding up the convergence of iteration methods.
USSR Computational Mathematics and Mathematical Physics, 4(5):1–17.
Reference regarding the Nesterov behavior:
Yurii Nesterov (1983).
A method for unconstrained convex minimization problem with the rate ofconvergence o(1/k2).
Doklady ANSSSR (translated as Soviet.Math.Docl.), 269:543–547.
Source code in evotorch/optimizers.py
__init__(*, solution_length, dtype, stepsize, device='cpu', momentum=None, dampening=None, nesterov=None)
¶
__init__(...)
: Initialize the SGD optimizer.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
solution_length
|
int
|
Length of a solution of the problem which is being worked on. |
required |
dtype
|
DType
|
The dtype of the problem which is being worked on. |
required |
stepsize
|
float
|
The step size (i.e. the learning rate) employed by the optimizer. |
required |
device
|
Device
|
The device on which the solutions are kept. |
'cpu'
|
momentum
|
Optional[float]
|
The momentum coefficient. None means the default. |
None
|
dampening
|
Optional[bool]
|
Whether or not to activate the dampening behavior.
None means the default.
See |
None
|
nesterov
|
Optional[bool]
|
Whether or not to activate the nesterov behavior.
None means the default.
See |
None
|
Source code in evotorch/optimizers.py
TorchOptimizer
¶
Base class for using a PyTorch optimizer
Source code in evotorch/optimizers.py
contained_optimizer
property
¶
Get the PyTorch optimizer contained by this wrapper
__init__(torch_optimizer, *, config, solution_length, dtype, device='cpu')
¶
__init__(...)
: Initialize the TorchOptimizer.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
torch_optimizer
|
Type
|
The class which represents a PyTorch optimizer. |
required |
config
|
dict
|
The configuration dictionary to be passed to the optimizer as keyword arguments. |
required |
solution_length
|
int
|
Length of a solution of the problem on which the optimizer will work. |
required |
dtype
|
DType
|
The dtype of the problem. |
required |
device
|
Device
|
The device on which the solutions are kept. |
'cpu'
|
Source code in evotorch/optimizers.py
ascent(globalg, *, cloned_result=True)
¶
Compute the ascent, i.e. the step to follow.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
globalg
|
RealOrVector
|
The estimated gradient. |
required |
cloned_result
|
bool
|
If |
True
|
Source code in evotorch/optimizers.py
get_optimizer_class(s, optimizer_config=None)
¶
Get the optimizer class from the given string.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
s
|
str
|
A string, referring to the optimizer class. "clipsgd", "clipsga", "clipup" refers to ClipUp. "adam" refers to Adam. "sgd" or "sga" refers to SGD. |
required |
optimizer_config
|
Optional[dict]
|
A dictionary containing the configurations to be passed to the optimizer. If this argument is not None, then, instead of the class being referred to, a dynamically generated factory function will be returned, which will pass these configurations to the actual class upon being called. |
None
|