diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c8195689..c032e5553 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,13 @@ # Changelog -## Release 1.2.0 +## Unreleased ### Changes/Improvements - trainer: - Custom scoring now supported for selecting the best model. #1202 +- highlevel: + - `DiscreteSACExperimentBuilder`: Expose method `with_actor_factory_default` #1248 #1250 ### Breaking Changes diff --git a/docs/04_contributing/04_contributing.rst b/docs/04_contributing/04_contributing.rst index 01764fc36..1397e3473 100644 --- a/docs/04_contributing/04_contributing.rst +++ b/docs/04_contributing/04_contributing.rst @@ -13,6 +13,17 @@ to install all relevant requirements in editable mode you can simply call $ poetry install --with dev +Platform-Specific Configuration +------------------------------- + +**Windows**: +Since the repository contains symbolic links, make sure this is supported: + + * Enable Windows Developer Mode to allow symbolic links to be created: Search Start Menu for "Developer Settings" and enable "Developer Mode" + * Enable symbolic links for this repository: ``git config core.symlinks true`` + * Re-checkout the current git state: ``git checkout .`` + + PEP8 Code Style Check and Formatting ---------------------------------------- diff --git a/tianshou/highlevel/experiment.py b/tianshou/highlevel/experiment.py index 774902b40..c0be23dca 100644 --- a/tianshou/highlevel/experiment.py +++ b/tianshou/highlevel/experiment.py @@ -801,6 +801,28 @@ def with_actor_factory_default( return super()._with_actor_factory_default(hidden_sizes, hidden_activation) +class _BuilderMixinActorFactory_DiscreteOnly(_BuilderMixinActorFactory): + """Specialization of the actor mixin where only environments with discrete action spaces are supported.""" + + def __init__(self) -> None: + super().__init__(ContinuousActorType.UNSUPPORTED) + + def with_actor_factory_default( + self, + hidden_sizes: Sequence[int], + hidden_activation: ModuleType = torch.nn.ReLU, + ) -> Self: + """Defines use of the default actor factory, allowing its parameters it to be customized. + + The default actor factory uses an MLP-style architecture. + + :param hidden_sizes: dimensions of hidden layers used by the network + :param hidden_activation: the activation function to use for hidden layers + :return: the builder + """ + return super()._with_actor_factory_default(hidden_sizes, hidden_activation) + + class _BuilderMixinCriticsFactory: def __init__(self, num_critics: int, actor_future_provider: ActorFutureProviderProtocol): self._actor_future_provider = actor_future_provider @@ -959,7 +981,7 @@ def with_critic2_factory_default( return self def with_critic2_factory_use_actor(self) -> Self: - """Makes the first critic reuse the actor's preprocessing network (parameter sharing).""" + """Makes the second critic reuse the actor's preprocessing network (parameter sharing).""" return self._with_critic_factory_use_actor(1) @@ -1333,7 +1355,7 @@ def _create_agent_factory(self) -> AgentFactory: class DiscreteSACExperimentBuilder( ExperimentBuilder, - _BuilderMixinActorFactory, + _BuilderMixinActorFactory_DiscreteOnly, _BuilderMixinDualCriticFactory, ): def __init__( @@ -1343,7 +1365,7 @@ def __init__( sampling_config: SamplingConfig | None = None, ): super().__init__(env_factory, experiment_config, sampling_config) - _BuilderMixinActorFactory.__init__(self, ContinuousActorType.UNSUPPORTED) + _BuilderMixinActorFactory_DiscreteOnly.__init__(self) _BuilderMixinDualCriticFactory.__init__(self, self) self._params: DiscreteSACParams = DiscreteSACParams()