persistence#


class PersistEvent(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]#

Enumeration of persistence events that Persistence objects can react to.

PERSIST_POLICY = 'persist_policy'#

Policy neural network is persisted (new best found)

class Persistence[source]#
abstract persist(event: PersistEvent, world: World) None[source]#
abstract restore(event: RestoreEvent, world: World) None[source]#
class PersistenceGroup(*p: Persistence, enabled: bool = True)[source]#

Groups persistence handler such that they can be applied collectively.

persist(event: PersistEvent, world: World) None[source]#
restore(event: RestoreEvent, world: World) None[source]#
class PolicyPersistence(additional_persistence: Persistence | None = None, enabled: bool = True, mode: Mode = Mode.POLICY)[source]#
class Mode(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]#

Mode of persistence.

POLICY = 'policy'#

Persist the entire policy. This is larger but has the advantage of the policy being loadable without requiring an environment to be instantiated. It has the potential disadvantage that upon breaking code changes in the policy implementation (e.g. renamed/moved class), it will no longer be loadable. Note that a precondition is that the policy be picklable in its entirety.

POLICY_STATE_DICT = 'policy_state_dict'#

Persist only the policy’s state dictionary. Note that for a policy to be restored from such a dictionary, it is necessary to first create a structurally equivalent object which can accept the respective state.

get_filename() str[source]#
get_save_best_fn(world: World) Callable[[Module], None][source]#
persist(policy: Module, world: World) None[source]#
restore(policy: Module, world: World, device: TDevice) None[source]#
class RestoreEvent(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]#

Enumeration of restoration events that Persistence objects can react to.

RESTORE_POLICY = 'restore_policy'#

Policy neural network parameters are restored