Funcsgd
sgd(*, center_init, center_learning_rate, momentum=None)
¶
Initialize the gradient ascent/descent search and get its initial state.
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.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
center_init
|
BatchableVector
|
Starting point for the gradient ascent/descent. Expected as a PyTorch tensor with at least 1 dimension. If there are 2 or more dimensions, the extra leftmost dimensions are interpreted as batch dimensions. |
required |
center_learning_rate
|
BatchableScalar
|
Learning rate (i.e. the step size) for gradient ascent/descent. Can be a scalar or a multidimensional tensor. If given as a tensor with multiple dimensions, those dimensions will be interpreted as batch dimensions. |
required |
momentum
|
Optional[BatchableScalar]
|
Momentum coefficient, expected as a scalar. If provided as a scalar, Polyak-style momentum will be enabled. If given as a tensor with multiple dimensions, those dimensions will be interpreted as batch dimensions. |
None
|
Source code in evotorch/algorithms/functional/funcsgd.py
sgd_ask(state)
¶
Get the search point stored by the given SGDState
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
state
|
SGDState
|
The current state of gradient ascent/descent. |
required |
Source code in evotorch/algorithms/functional/funcsgd.py
sgd_tell(state, *, follow_grad)
¶
Tell the gradient ascent/descent the current gradient to get its next state.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
state
|
SGDState
|
The current state of gradient ascent/descent. |
required |
follow_grad
|
BatchableVector
|
Gradient at the current point of the search. Can be a 1-dimensional tensor in the non-batched case, or a multi-dimensional tensor in the batched case. |
required |