Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/source/concepts/configuring.rst
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ You can change it like so:

.. code-block:: console

python benchmarl/run.py task=vmas/balance algorithm=mappo model=layers/mlp model=layers/mlp model.layer_class="torch.nn.Linear" "model.num_cells=[32,32]" model.activation_class="torch.nn.ReLU"
python benchmarl/run.py task=vmas/balance algorithm=mappo model=layers/mlp model.layer_class="torch.nn.Linear" "model.num_cells=[32,32]" model.activation_class="torch.nn.ReLU"


Available models and their configs can be found at `benchmarl/conf/model/layers <https://github.com/facebookresearch/BenchMARL/blob/main/benchmarl/conf/model/layers>`__.
Expand Down
6 changes: 3 additions & 3 deletions examples/extending/model/custom_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class CustomModel(Model):
def __init__(
self,
custom_param: int,
activation_function: Type[nn.Module],
activation_class: Type[nn.Module],
**kwargs,
):
# Models in BenchMARL are instantiated per agent group.
Expand All @@ -34,7 +34,7 @@ def __init__(

# You can create your custom attributes
self.custom_param = custom_param
self.activation_function = activation_function
self.activation_function = activation_class

# And access some of the ones already available to your module
_ = self.input_spec # Like its input_spec
Expand Down Expand Up @@ -166,7 +166,7 @@ def _forward(self, tensordict: TensorDictBase) -> TensorDictBase:
class CustomModelConfig(ModelConfig):
# The config parameters for this class, these will be loaded from yaml
custom_param: int = MISSING
activation_function: Type[nn.Module] = MISSING
activation_class: Type[nn.Module] = MISSING

@staticmethod
def associated_class():
Expand Down
2 changes: 1 addition & 1 deletion examples/extending/model/custommodel.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

name: custom_model
custom_param: 3
activation_function: torch.nn.Tanh
activation_class: torch.nn.Tanh