Closed engintoklu closed 4 months ago
Attention: 113 lines
in your changes are missing coverage. Please review.
Comparison is base (
5c58566
) 76.74% compared to head (8224905
) 77.36%.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
This pull request introduces an alternative API for EvoTorch that conforms to the functional programming paradigm. This functional API can be used together with
torch.func.vmap
, and therefore can be used for optimizing not just a single population, but a batch of populations simultaneously.The main improvements are:
cem
) and policy gradients with parameter-based exploration (pgpe
) are implemented. These algorithm implementations can be used withvmap
, or can be given batches of starting points (center_init
arguments) so that they will generate batches of populations centered around them.adam
,clipup
, andsgd
are implemented. The interfaces of these optimizers are similar to the interfaces of functionalcem
andpgpe
. Therefore, the user can switch back and forth between evolutionary approach and gradient-based approach for solving a problem, with minimum amount of code change.@expects_ndim
is introduced. This decorator is used for declaring how many dimensions are expected per each positional argument of the decorated function. Upon receiving tensors whose number of dimensions are more than expected, the decorated function interprets those tensors as batched arguments, appliesvmap
on itself, and performs its operations across the batch dimensions.@rowwise
is introduced. This decorator is used for declaring that a function is implemented with the assumption that its argument is a vector. If it receives a tensor with 2 or more dimensions, the function appliesvmap
on itself, and performs its operations across multiple batch dimensions.