velora.state¶
Documentation
Dataclasses for storing states used during callbacks and agent training.
AnalyticsState
dataclass
¶
A storage container for the details of a Comet or Weights and Biases analytics experiment.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_name
|
str
|
the name of the project to add this experiment to |
required |
experiment_name
|
str
|
the name of the experiment |
None
|
tags
|
List[str]
|
a list of tags associated with the experiment |
None
|
Source code in velora/state.py
Python | |
---|---|
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
|
RecordState
dataclass
¶
A storage container for the video recording state.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dirpath
|
Path
|
the video directory path to store the videos |
required |
method
|
Literal['episode', 'step']
|
the recording method |
required |
episode_trigger
|
Callable[[int], bool]
|
the |
None
|
step_trigger
|
Callable[[int], bool]
|
the |
None
|
Source code in velora/state.py
Python | |
---|---|
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
|
to_wrapper()
¶
Converts the state into wrapper parameters.
Returns:
Name | Type | Description |
---|---|---|
params |
Dict[str, Any]
|
values as parameters for Gymnasium's RecordVideo wrapper. |
Dict[str, Any]
|
Includes the following keys - |
Source code in velora/state.py
Python | |
---|---|
32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
|
TrainState
dataclass
¶
A storage container for the current state of model training.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
agent
|
RLModuleAgent
|
the agent being trained |
required |
env
|
gymnasium.Env
|
a single training or evaluation environment |
required |
session
|
sqlmodel.Session
|
the current metric database session |
required |
experiment_id
|
int
|
the current experiment's unique ID |
required |
total_episodes
|
int
|
total number of training episodes |
0
|
total_steps
|
int
|
total number of training steps |
0
|
status
|
Literal['start', 'episode', 'logging', 'step', 'complete']
|
the current stage of training.
|
'start'
|
logging_type
|
Literal['episode', 'step']
|
the logging type |
'episode'
|
current_ep
|
int
|
the current episode index |
0
|
current_step
|
int
|
the current training timestep |
0
|
ep_reward
|
float
|
the current episode reward |
0.0
|
stop_training
|
bool
|
a flag to declare training termination |
False
|
saving_enabled
|
bool
|
a flag for checkpoint saving |
False
|
checkpoint_dir
|
Path
|
the checkpoint directory path when
|
None
|
record_state
|
RecordState
|
the video recording state |
None
|
analytics_state
|
AnalyticsState
|
the analytics state |
None
|
Source code in velora/state.py
Python | |
---|---|
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
|
analytics_update()
¶
Updates the analytics state details that are None
dynamically, using
the current training state.
Source code in velora/state.py
Python | |
---|---|
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
|
update(*, status=None, current_ep=None, current_step=None, ep_reward=None, logging_type=None)
¶
Updates the training state. When any input is None
, uses existing value.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
status
|
Literal['start', 'episode', 'logging', 'step', 'complete']
|
the current stage of training.
|
None
|
current_ep
|
int
|
the current episode index |
None
|
current_step
|
int
|
the current training timestep |
None
|
ep_reward
|
float
|
the current episode or rollout update reward |
None
|
logging_type
|
Literal['episode', 'step']
|
the logging type |
None
|
Source code in velora/state.py
Python | |
---|---|
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
|