ray.rllib.algorithms.algorithm_config.AlgorithmConfig#

class ray.rllib.algorithms.algorithm_config.AlgorithmConfig(algo_class=None)[source]#

Bases: ray.tune.tune._Config

A RLlib AlgorithmConfig builds an RLlib Algorithm from a given configuration.

Example

>>> from ray.rllib.algorithms.algorithm_config import AlgorithmConfig
>>> from ray.rllib.algorithms.callbacks import MemoryTrackingCallbacks
>>> # Construct a generic config object, specifying values within different
>>> # sub-categories, e.g. "training".
>>> config = AlgorithmConfig().training(gamma=0.9, lr=0.01)  
...     .environment(env="CartPole-v1")
...     .resources(num_gpus=0)
...     .rollouts(num_rollout_workers=4)
...     .callbacks(MemoryTrackingCallbacks)
>>> # A config object can be used to construct the respective Trainer.
>>> rllib_algo = config.build()  

Example

>>> from ray.rllib.algorithms.algorithm_config import AlgorithmConfig
>>> from ray import tune
>>> # In combination with a tune.grid_search:
>>> config = AlgorithmConfig()
>>> config.training(lr=tune.grid_search([0.01, 0.001])) 
>>> # Use `to_dict()` method to get the legacy plain python config dict
>>> # for usage with `tune.Tuner().fit()`.
>>> tune.Tuner(  
...     "[registered trainer class]", param_space=config.to_dict()
...     ).fit()

Methods

build([env, logger_creator, use_copy])

Builds an Algorithm from this AlgorithmConfig (or a copy thereof).

callbacks(callbacks_class)

Sets the callbacks configuration.

checkpointing([export_native_model_files, ...])

Sets the config's checkpointing settings.

copy([copy_frozen])

Creates a deep copy of this config and (un)freezes if necessary.

debugging(*[, logger_creator, ...])

Sets the config's debugging settings.

environment([env, env_config, ...])

Sets the config's RL-environment settings.

evaluation(*[, evaluation_interval, ...])

Sets the config's evaluation settings.

experimental(*[, ...])

Sets the config's experimental settings.

exploration(*[, explore, exploration_config])

Sets the config's exploration settings.

fault_tolerance([recreate_failed_workers, ...])

Sets the config's fault tolerance settings.

framework([framework, eager_tracing, ...])

Sets the config's DL framework settings.

freeze()

Freezes this config object, such that no attributes can be set anymore.

from_dict(config_dict)

Creates an AlgorithmConfig from a legacy python config dict.

get(key[, default])

Shim method to help pretend we are a dict.

get_default_learner_class()

Returns the Learner class to use for this algorithm.

get_default_rl_module_spec()

Returns the RLModule spec to use for this algorithm.

get_evaluation_config_object()

Creates a full AlgorithmConfig object from self.evaluation_config.

get_learner_hyperparameters()

Returns a new LearnerHyperparameters instance for the respective Learner.

get_marl_module_spec(*, policy_dict[, ...])

Returns the MultiAgentRLModule spec based on the given policy spec dict.

get_multi_agent_setup(*[, policies, env, ...])

Compiles complete multi-agent config (dict) from the information in self.

get_rollout_fragment_length([worker_index])

Automatically infers a proper rollout_fragment_length setting if "auto".

is_multi_agent()

Returns whether this config specifies a multi-agent setup.

items()

Shim method to help pretend we are a dict.

keys()

Shim method to help pretend we are a dict.

multi_agent(*[, policies, ...])

Sets the config's multi-agent settings.

offline_data(*[, input_, input_config, ...])

Sets the config's offline data settings.

overrides(**kwargs)

Generates and validates a set of config key/value pairs (passed via kwargs).

pop(key[, default])

Shim method to help pretend we are a dict.

python_environment(*[, ...])

Sets the config's python environment settings.

reporting(*[, ...])

Sets the config's reporting settings.

resources(*[, num_gpus, _fake_gpus, ...])

Specifies resources allocated for an Algorithm and its ray actors/workers.

rl_module(*[, rl_module_spec, ...])

Sets the config's RLModule settings.

rollouts(*[, num_rollout_workers, ...])

Sets the rollout worker configuration.

serialize()

Returns a mapping from str to JSON'able values representing this config.

to_dict()

Converts all settings into a legacy config dict for backward compatibility.

training(*[, gamma, lr, lr_schedule, ...])

Sets the training related configuration.

update_from_dict(config_dict)

Modifies this AlgorithmConfig via the provided python config dict.

validate()

Validates all values in this config.

validate_train_batch_size_vs_rollout_fragment_length()

Detects mismatches for train_batch_size vs rollout_fragment_length.

values()

Shim method to help pretend we are a dict.

Attributes

learner_class

Returns the Learner sub-class to use by this Algorithm.

multiagent

Shim method to help pretend we are a dict with 'multiagent' key.

num_workers