Skip to main content

Module continuous_q

Module continuous_q 

Source
Expand description

Continuous-action Q(s, a) critic for SAC (twin critics + targets), with hard and Polyak (soft) target-sync helpers. Burn-backend continuous-action Q-critic for SAC (part of #136).

ContinuousQNetwork is the Q(s, a) critic SAC uses for its twin critics and the two target critics. It is structurally close to the discrete crate::policy::q_network::QNetworkBurn, but differs in two ways that match the continuous-control setting:

  • Input width is obs_dim + action_dim — the forward pass concatenates the observation and the continuous action along the feature axis before the trunk, so the critic scores a specific (state, action) pair rather than every discrete action at once.
  • Output width is 1 — a single scalar Q(s, a) per batch row.

§Architecture

obs    [batch, obs_dim]   ┐
                          ├─ concat → [batch, obs_dim + action_dim]
action [batch, action_dim]┘
    → fc1 →act→ fc2 →act→ (fc3 →act→)? q_head
 Q(s, a) [batch]

The trunk depth (2 or 3 layers), hidden width, activation, and init recipe are configurable via ContinuousQNetworkConfig, mirroring crate::policy::mlp::MlpBurnConfig. Construction can be seeded for bit-exact reproducibility (see crate::policy::seeded_init).

§Twin critics + targets

The module owns no optimizer and no target state of its own — Burn’s optimizer consumes a module by value per step, so SAC’s future SacTrainer owns four independent instances (q1, q2, q1_target, q2_target) as separate fields and steps the two online critics independently. Instantiating two twins with different seeds (or different unseeded draws) yields decorrelated critics, which is the standard clipped-double-Q setup.

§Target-net sync

Two helpers mirror the record-based approach documented on crate::policy::q_network::QNetworkBurn:

  • copy_params_from — hard copy (theta_target <- theta_online), used to initialize the targets.
  • soft_update_from — Polyak blend (theta_target <- tau * theta_online + (1 - tau) * theta_target), used every step in SAC. tau = 1.0 reduces exactly to a hard copy.

Structs§

ContinuousQNetwork
Continuous-action Q-critic on Burn: Q(s, a) -> scalar.
ContinuousQNetworkConfig
Configuration for ContinuousQNetwork architecture.
ContinuousQNetworkRecord
The record type for the module.
ContinuousQNetworkRecordItem
The record item type for the module.