xpag.agents.flax_agents.sac.sac_from_jaxrl#

This is the SAC agent from JAXRL (https://github.com/ikostrikov/jaxrl), put in a single file (without the buffer). It implements the version of Soft-Actor-Critic described in https://arxiv.org/abs/1812.05905.

The main modifications are:
  • the save() and load() methods of the Model class,

  • the removal of the dependency to tqdm,

  • the split of _sample_actions() into _sample_actions_deterministic() and _sample_actions_probabilistic(),

  • the inclusion of the parameter ‘distribution’ in the method sample_actions() of the class SACLearner.

To understand the code, the best is to check it on https://github.com/ikostrikov/jaxrl, where there is a coherent structure and separated files. The purpose here is just to have access to the SAC agent from JAXRL without requiring all the JAXRL dependencies.

Here is the JAXRL License: MIT License

Copyright (c) 2021 Ilya Kostrikov

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Functions

default_init

sample_actions

rtype:

Tuple[Any, Array]

target_update

rtype:

Model

update_actor

rtype:

Tuple[Model, Dict[str, float]]

update_critic

rtype:

Tuple[Model, Dict[str, float]]

update_temperature

rtype:

Tuple[Model, Dict[str, float]]

Classes

Batch

Create new instance of Batch(observations, actions, rewards, masks, next_observations)

Critic

DoubleCritic

MLP

Model

SACLearner

An implementation of the version of Soft-Actor-Critic described in https://arxiv.org/abs/1812.05905

Temperature