DreamerConfig
WorldModelConfigDreamerConfig(sample_size: int | tuple[int, int] = WORLD_MODEL_IMAGE_SIZE, in_channels: int = 3, out_channels: int = 3, act_fn: GenerativeActivation = 'elu', action_dim: int = 1, stoch_size: int = 30, deter_size: int = 200, hidden_size: int = 200, cnn_depth: int = 32, min_std: float = 0.1, mean_only: bool = False, free_nats: float = 3.0, kl_weight: float = 1.0, cnn_act: GenerativeActivation = 'relu', horizon: int = 15, discount: float = 0.99, lambda_: float = 0.95, actor_hidden: int = 300, actor_layers: int = 3, value_hidden: int = 300, value_layers: int = 3, actor_min_std: float = 0.0001, actor_init_std: float = 5.0, actor_mean_scale: float = 5.0, reward_hidden: int = 300, reward_layers: int = 3, detach_actor_input: bool = True, pcont: bool = False, pcont_scale: float = 10.0, pcont_layers: int = 3, action_space: str = 'continuous')Frozen configuration for the Dreamer family.
Defaults reproduce Hafner et al., 2020 on the DeepMind Control Suite.
Fields shared with PlaNet are inherited from WorldModelConfig.
Parameters
act_fn(silu, swish, relu, gelu, elu)= "silu"cnn_act(silu, swish, relu, gelu, elu)= "silu"dense_act is ELU and
cnn_act is ReLU — and the paper states the first while
saying nothing about the second, so this follows the rule the
rest of this class uses when the paper is silent.horizonint= 15discountfloat= 0.99lambda_float= 0.95lambda is a keyword.actor_hiddenint= 300, 3actor_layersint= 300, 3value_hiddenint= 300, 3value_layersint= 300, 3actor_min_stdfloat= 1e-4actor_init_stdfloat= 5.0softplus so the policy starts wide enough
to explore.actor_mean_scalefloat= 5.0s * tanh(x / s) before squashing,
which keeps it from saturating the outer tanh.reward_hiddenint= 300, 3reward_layersint= 300, 3detach_actor_inputbool= TrueFalse gives the exact gradient of the stated objective
— see Notes.pcontbool= Falsepcont_scalefloat= 10.0pcont_layersint= 3value_hidden.action_space(continuous, discrete)= "continuous""continuous" is the tanh-squashed Gaussian
the Control Suite needs. "discrete" makes the action model
"predict the logits of a categorical distribution", which is what
the paper's Discrete control paragraph specifies for Atari and
DeepMind Lab, sampled with straight-through gradients so the
actor's gradient still arrives through the action.Notes
Reference: Hafner, Lillicrap, Ba, and Norouzi, "Dream to Control: Learning Behaviors by Latent Imagination", ICLR, 2020 (arXiv:1912.01603).
The actor emits a tanh-squashed diagonal Gaussian, so actions are
bounded to (-1, 1) — the Control Suite's range. actor_min_std,
actor_init_std and actor_mean_scale are not stated in the
paper; they are the released implementation's, and are exposed here
rather than buried so a reader can see which numbers have a citation
and which have a source.
Where the paper and the released implementation disagree, the paper wins and the difference is recorded here rather than hidden:
============== ==================== ========================== quantity paper released implementation ============== ==================== ========================== head width 300 400 throughout actor depth 3 4 value depth 3 3 reward depth not stated 2 (taken, as the default) CNN activation not stated ReLU (taken; dense stays ELU) ============== ==================== ==========================
detach_actor_input is the one behavioural fork. The released
implementation feeds the actor a stop_gradient-ed state during
imagination, which drops the terms in which a return depends on the
policy through the state it read. Keeping them (False) is the
exact gradient of ;
dropping them is cheaper and lower-variance. The default follows the
released implementation because the paper is silent.
The three losses need three optimisers over three parameter groups
— see DreamerForWorldModeling. Summing them and taking one
step is not this algorithm: the actor's gradient would then also
descend the world model, and the critic would chase a target it is
simultaneously moving.
Examples
>>> from lucid.models.generative.dreamer import DreamerConfig
>>> cfg = DreamerConfig(action_dim=6)
>>> cfg.horizon, cfg.lambda_, cfg.discount
(15, 0.95, 0.99)
>>> cfg.act_fn
'elu'Used by 3
Constructors
1__init__
→None__init__(sample_size: int | tuple[int, int] = WORLD_MODEL_IMAGE_SIZE, in_channels: int = 3, out_channels: int = 3, act_fn: GenerativeActivation = 'elu', action_dim: int = 1, stoch_size: int = 30, deter_size: int = 200, hidden_size: int = 200, cnn_depth: int = 32, min_std: float = 0.1, mean_only: bool = False, free_nats: float = 3.0, kl_weight: float = 1.0, cnn_act: GenerativeActivation = 'relu', horizon: int = 15, discount: float = 0.99, lambda_: float = 0.95, actor_hidden: int = 300, actor_layers: int = 3, value_hidden: int = 300, value_layers: int = 3, actor_min_std: float = 0.0001, actor_init_std: float = 5.0, actor_mean_scale: float = 5.0, reward_hidden: int = 300, reward_layers: int = 3, detach_actor_input: bool = True, pcont: bool = False, pcont_scale: float = 10.0, pcont_layers: int = 3, action_space: str = 'continuous')Initialise the actor. See the class docstring for parameters.