releso.validation.Validation
- class releso.validation.Validation(*, save_location: Path, logger_name: str | None = None, validation_freq: ConstrainedIntValue | None = None, validation_values: ConstrainedListValue[float], save_best_agent: bool, validate_on_training_end: bool, max_timesteps_in_episode: ConstrainedIntValue | None = None, end_episode_on_geometry_not_changed: bool = False, reward_on_geometry_not_changed: float | None = None, reward_on_episode_exceeds_max_timesteps: float | None = None)
Bases:
BaseModelParser class to define the validation to be performed during training.
This class is used for the configuration of how validation is to be performed during training.
- __init__(**data: Any) None
Constructor for the ReLeSO basemodel object.
Methods
convert_to_pathlib_add_datetime(v)Add timestamp to save_location, of applicable.
end_validation(agent, environment)Function is called at the end of a validation.
get_callback(eval_environment[, ...])Creates the EvalCallback with the values given in this object.
Gather the validation arguments used to initialize validator.
get_logger()Gets the currently defined environment logger.
set_logger_name_recursively(logger_name)Set the logger_name variable for all child elements.
Bool function whether or not a validation callback is needed.
Attributes
How many timesteps should pass by learning between validation runs
List of validation items.
Whether or not to save the best agent.
after how many timesteps inside a single episode should the episode be terminated.
Should the episode be terminated if the geometry representation has not changed between timesteps?
What reward should be added to the step reward if the geometry was not changed for the defined number of steps.
What reward should be added to the step reward if the maximal timesteps per episode is exceeded.
save_locationDefinition of the save location of the logs and validation results.
logger_namename of the logger.
- end_episode_on_geometry_not_changed: bool
Should the episode be terminated if the geometry representation has not changed between timesteps?
- end_validation(agent: BaseAlgorithm, environment: gymnasium.Env | VecEnv) Tuple[float, float]
Function is called at the end of a validation.
All clean up and last evaluation is going in here.
- Parameters:
agent (BaseAlgorithm) – Agent which is to be used to validate.
environment (GymEnv) – Validation environment
- Returns:
See ‘funct’evaluate_policy() for definition
- Return type:
Tuple[float, float]
- get_callback(eval_environment: gymnasium.Env | VecEnv, save_location: Path | None = None, normalizer_divisor: int = 1) EvalCallback
Creates the EvalCallback with the values given in this object.
- Parameters:
eval_environment (GymEnv) – Evaluation environment. Should be the same as the normal training environment only that here the goal values should be set and not random.
save_location (Optional[pathlib.Path]) – Path to where the best models should be save to.
normalizer_divisor (int, optional) – Divisor for the eval_freq. Defaults to 1.
- Returns:
Validation callback parametrized by this object.
- Return type:
EvalCallback
- get_environment_validation_parameters() Dict[str, Any]
Gather the validation arguments used to initialize validator.
Gets the validation parameters that need to be send to the environment if it gets converted to be a validation environment.
- Returns:
dict with all the necessary parameters. Should mirror the parameters in parser_environment.Environment.set_validation
- Return type:
Dict[str, Any]
- max_timesteps_in_episode: ConstrainedIntValue | None
after how many timesteps inside a single episode should the episode be terminated.
- reward_on_episode_exceeds_max_timesteps: float | None
What reward should be added to the step reward if the maximal timesteps per episode is exceeded.
- reward_on_geometry_not_changed: float | None
What reward should be added to the step reward if the geometry was not changed for the defined number of steps.
- save_best_agent: bool
Whether or not to save the best agent. If agent is not saved only results will be reported by the agent which produced them will not be saved.
- should_add_callback() bool
Bool function whether or not a validation callback is needed.
- Returns:
Return True if a validation callback is needed else False.
- Return type:
bool
- validation_freq: ConstrainedIntValue | None
How many timesteps should pass by learning between validation runs
- validation_values: ConstrainedListValue[float]
List of validation items. This will be revised later on #TODO