DummyEvolvable¶
Converts a torch.nn.Module
into an evolvable module. This is useful when users wish to load a pre-trained model that is not
an agilerl.modules.EvolvableModule
and use it in an evolvable AgileRL algorithm, disabling architecture mutations but still
allowing for RL hyperparameter and weight mutations.
Parameters¶
- class agilerl.modules.dummy.DummyEvolvable(*args, **kwargs)¶
Wrapper to convert a PyTorch nn.Module into an EvolvableModule object.
Note
This doesn’t actually allow the user to mutate its architecture, but rather allows us to use nn.Module objects as networks in an
EvolvableAlgorithm
. If a user wants to mutate the architecture of a network, they should create their network using theEvolvableModule
class hierarchy directly. Please refer to the documentation for more information on how to do this.- Parameters:
module_fn (Callable[[], nn.Module]) – Function that returns a PyTorch nn.Module object.
module_kwargs (Dict[str, Any]) – Keyword arguments to pass to the module_fn.
device (DeviceType) – Device to run the module on.
- change_activation(activation: str, output: bool) None ¶
Set the activation function for the network.
- Parameters:
activation (str) – Activation function to use.
- forward(*args, **kwargs) Tensor ¶
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Module
instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.