Rate this Page

DreamerV3UpdateRatio#

class torchrl.trainers.algorithms.DreamerV3UpdateRatio(ratio: float)[source]#

Schedule learner updates from a ratio of updates to driver records.

Each call truncates the count from the cumulative driver-record count and keeps the remainder. The first call returns one update.

Parameters:

ratio (float) – Learner updates for each driver record. Non-positive values disable updates.

Examples

>>> from torchrl.trainers.algorithms import DreamerV3UpdateRatio
>>> schedule = DreamerV3UpdateRatio(0.25)
>>> schedule(4), schedule(6)
(1, 0)
>>> saved = schedule.state_dict()
>>> expected = schedule(8)
>>> schedule.load_state_dict(saved)
>>> schedule(8) == expected
True
load_state_dict(state_dict: Mapping[str, float | None]) None[source]#

Restore the update schedule’s progress and ratio.

reset(record_count: int) None[source]#

Discard owed updates and start counting after record_count records.

Use when rebuilding replay after a resume without saved replay, so collection warm-up does not accumulate a catch-up update burst.

state_dict() dict[str, float | None][source]#

Return the ratio and cumulative progress, including fractional updates.