rllib/agents/trainer_config.py
def evaluation(
        self,
        *,
        evaluation_interval: Optional[int] = None,
        evaluation_duration: Optional[int] = None,
        evaluation_duration_unit: Optional[str] = None,
        evaluation_parallel_to_training: Optional[bool] = None,
        evaluation_config: Optional[
            Union["TrainerConfig", PartialTrainerConfigDict]
        ] = None,
        evaluation_num_workers: Optional[int] = None,
        custom_evaluation_function: Optional[Callable] = None,
        always_attach_evaluation_results: Optional[bool] = None,
    ) -> "TrainerConfig":
        """Sets the config's evaluation settings.

        Args:
            evaluation_interval: Evaluate with every `evaluation_interval` training
                iterations. The evaluation stats will be reported under the "evaluation"
                metric key. Note that for Ape-X metrics are already only reported for
                the lowest epsilon workers (least random workers).
                Set to None (or 0) for no evaluation.
            evaluation_duration: Duration for which to run evaluation each
                `evaluation_interval`. The unit for the duration can be set via
                `evaluation_duration_unit` to either "episodes" (default) or
                "timesteps". If using multiple evaluation workers
                (evaluation_num_workers > 1), the load to run will be split amongst
                these.
                If the value is "auto":
                - For `evaluation_parallel_to_training=True`: Will run as many
                episodes/timesteps that fit into the (parallel) training step.
                - For `evaluation_parallel_to_training=False`: Error.
            evaluation_duration_unit: The unit, with which to count the evaluation
                duration. Either "episodes" (default) or "timesteps".
            evaluation_parallel_to_training: Whether to run evaluation in parallel to
                a Trainer.train() call using threading. Default=False.
                E.g. evaluation_interval=2 -> For every other training iteration,
                the Trainer.train() and Trainer.evaluate() calls run in parallel.
                Note: This is experimental. Possible pitfalls could be race conditions
                for weight synching at the beginning of the evaluation loop.
            evaluation_config: Typical usage is to pass extra args to evaluation env
                creator and to disable exploration by computing deterministic actions.
                IMPORTANT NOTE: Policy gradient algorithms are able to find the optimal
                policy, even if this is a stochastic one. Setting "explore=False" here
                will result in the evaluation workers not using this optimal policy!
            evaluation_num_workers: Number of parallel workers to use for evaluation.
                Note that this is set to zero by default, which means evaluation will
                be run in the trainer process (only if evaluation_interval is not None).
                If you increase this, it will increase the Ray resource usage of the
                trainer since evaluation workers are created separately from rollout
                workers (used to sample data for training).
            custom_evaluation_function: Customize the evaluation method. This must be a
                function of signature (trainer: Trainer, eval_workers: WorkerSet) ->
                metrics: dict. See the Trainer.evaluate() method to see the default
                implementation. The Trainer guarantees all eval workers have the latest
                policy state before this function is called.
            always_attach_evaluation_results: Make sure the latest available evaluation
                results are always attached to a step result dict. This may be useful
                if Tune or some other meta controller needs access to evaluation metrics
                all the time.

        Returns:
            This updated TrainerConfig object.
        """
        if evaluation_interval is not None:
            self.evaluation_interval = evaluation_interval
        if evaluation_duration is not None:
            self.evaluation_duration = evaluation_duration
        if evaluation_duration_unit is not None:
            self.evaluation_duration_unit = evaluation_duration_unit
        if evaluation_parallel_to_training is not None:
            self.evaluation_parallel_to_training = evaluation_parallel_to_training
        if evaluation_config is not None:
            # Convert another TrainerConfig into dict.
            if isinstance(evaluation_config, TrainerConfig):
                self.evaluation_config = evaluation_config.to_dict()
            else:
                self.evaluation_config = evaluation_config
        if evaluation_num_workers is not None:
            self.evaluation_num_workers = evaluation_num_workers
        if custom_evaluation_function is not None:
            self.custom_evaluation_function = custom_evaluation_function
        if self.always_attach_evaluation_results:
            self.always_attach_evaluation_results = always_attach_evaluation_results

        return self
Sets the config's evaluation settings.

        Args:
            evaluation_interval: Evaluate with every `evaluation_interval` training
                iterations. The evaluation stats will be reported under the "evaluation"
                metric key. Note that for Ape-X metrics are already only reported for
                the lowest epsilon workers (least random workers).
                Set to None (or 0) for no evaluation.
            evaluation_duration: Duration for which to run evaluation each
                `evaluation_interval`. The unit for the duration can be set via
                `evaluation_duration_unit` to either "episodes" (default) or
                "timesteps". If using multiple evaluation workers
                (evaluation_num_workers > 1), the load to run will be split amongst
                these.
                If the value is "auto":
                - For `evaluation_parallel_to_training=True`: Will run as many
                episodes/timesteps that fit into the (parallel) training step.
                - For `evaluation_parallel_to_training=False`: Error.
            evaluation_duration_unit: The unit, with which to count the evaluation
                duration. Either "episodes" (default) or "timesteps".
            evaluation_parallel_to_training: Whether to run evaluation in parallel to
                a Trainer.train() call using threading. Default=False.
                E.g. evaluation_interval=2 -> For every other training iteration,
                the Trainer.train() and Trainer.evaluate() calls run in parallel.
                Note: This is experimental. Possible pitfalls could be race conditions
                for weight synching at the beginning of the evaluation loop.
            evaluation_config: Typical usage is to pass extra args to evaluation env
                creator and to disable exploration by computing deterministic actions.
                IMPORTANT NOTE: Policy gradient algorithms are able to find the optimal
                policy, even if this is a stochastic one. Setting "explore=False" here
                will result in the evaluation workers not using this optimal policy!
            evaluation_num_workers: Number of parallel workers to use for evaluation.
                Note that this is set to zero by default, which means evaluation will
                be run in the trainer process (only if evaluation_interval is not None).
                If you increase this, it will increase the Ray resource usage of the
                trainer since evaluation workers are created separately from rollout
                workers (used to sample data for training).
            custom_evaluation_function: Customize the evaluation method. This must be a
                function of signature (trainer: Trainer, eval_workers: WorkerSet) ->
                metrics: dict. See the Trainer.evaluate() method to see the default
                implementation. The Trainer guarantees all eval workers have the latest
                policy state before this function is called.
            always_attach_evaluation_results: Make sure the latest available evaluation
                results are always attached to a step result dict. This may be useful
                if Tune or some other meta controller needs access to evaluation metrics
                all the time.

        Returns:
            This updated TrainerConfig object.
        
Sets the config's evaluation settings.
Sets the config ' s evaluation settings .
def evaluation(
        self,
        *,
        evaluation_interval: Optional[int] = None,
        evaluation_duration: Optional[int] = None,
        evaluation_duration_unit: Optional[str] = None,
        evaluation_parallel_to_training: Optional[bool] = None,
        evaluation_config: Optional[
            Union["TrainerConfig", PartialTrainerConfigDict]
        ] = None,
        evaluation_num_workers: Optional[int] = None,
        custom_evaluation_function: Optional[Callable] = None,
        always_attach_evaluation_results: Optional[bool] = None,
    ) -> "TrainerConfig":
        if evaluation_interval is not None:
            self.evaluation_interval = evaluation_interval
        if evaluation_duration is not None:
            self.evaluation_duration = evaluation_duration
        if evaluation_duration_unit is not None:
            self.evaluation_duration_unit = evaluation_duration_unit
        if evaluation_parallel_to_training is not None:
            self.evaluation_parallel_to_training = evaluation_parallel_to_training
        if evaluation_config is not None:
            if isinstance(evaluation_config, TrainerConfig):
                self.evaluation_config = evaluation_config.to_dict()
            else:
                self.evaluation_config = evaluation_config
        if evaluation_num_workers is not None:
            self.evaluation_num_workers = evaluation_num_workers
        if custom_evaluation_function is not None:
            self.custom_evaluation_function = custom_evaluation_function
        if self.always_attach_evaluation_results:
            self.always_attach_evaluation_results = always_attach_evaluation_results
        return self
def evaluation ( self , * , evaluation_interval : Optional [ int ] = None , evaluation_duration : Optional [ int ] = None , evaluation_duration_unit : Optional [ str ] = None , evaluation_parallel_to_training : Optional [ bool ] = None , evaluation_config : Optional [ Union [ "TrainerConfig" , PartialTrainerConfigDict ] ] = None , evaluation_num_workers : Optional [ int ] = None , custom_evaluation_function : Optional [ Callable ] = None , always_attach_evaluation_results : Optional [ bool ] = None , ) -> "TrainerConfig" : if evaluation_interval is not None : self . evaluation_interval = evaluation_interval if evaluation_duration is not None : self . evaluation_duration = evaluation_duration if evaluation_duration_unit is not None : self . evaluation_duration_unit = evaluation_duration_unit if evaluation_parallel_to_training is not None : self . evaluation_parallel_to_training = evaluation_parallel_to_training if evaluation_config is not None : if isinstance ( evaluation_config , TrainerConfig ) : self . evaluation_config = evaluation_config . to_dict ( ) else : self . evaluation_config = evaluation_config if evaluation_num_workers is not None : self . evaluation_num_workers = evaluation_num_workers if custom_evaluation_function is not None : self . custom_evaluation_function = custom_evaluation_function if self . always_attach_evaluation_results : self . always_attach_evaluation_results = always_attach_evaluation_results return self
Sets the config's evaluation settings.
Sets the config ' s evaluation settings .
"""Sets the config's evaluation settings.

        Args:
            evaluation_interval: Evaluate with every `evaluation_interval` training
                iterations. The evaluation stats will be reported under the "evaluation"
                metric key. Note that for Ape-X metrics are already only reported for
                the lowest epsilon workers (least random workers).
                Set to None (or 0) for no evaluation.
            evaluation_duration: Duration for which to run evaluation each
                `evaluation_interval`. The unit for the duration can be set via
                `evaluation_duration_unit` to either "episodes" (default) or
                "timesteps". If using multiple evaluation workers
                (evaluation_num_workers > 1), the load to run will be split amongst
                these.
                If the value is "auto":
                - For `evaluation_parallel_to_training=True`: Will run as many
                episodes/timesteps that fit into the (parallel) training step.
                - For `evaluation_parallel_to_training=False`: Error.
            evaluation_duration_unit: The unit, with which to count the evaluation
                duration. Either "episodes" (default) or "timesteps".
            evaluation_parallel_to_training: Whether to run evaluation in parallel to
                a Trainer.train() call using threading. Default=False.
                E.g. evaluation_interval=2 -> For every other training iteration,
                the Trainer.train() and Trainer.evaluate() calls run in parallel.
                Note: This is experimental. Possible pitfalls could be race conditions
                for weight synching at the beginning of the evaluation loop.
            evaluation_config: Typical usage is to pass extra args to evaluation env
                creator and to disable exploration by computing deterministic actions.
                IMPORTANT NOTE: Policy gradient algorithms are able to find the optimal
                policy, even if this is a stochastic one. Setting "explore=False" here
                will result in the evaluation workers not using this optimal policy!
            evaluation_num_workers: Number of parallel workers to use for evaluation.
                Note that this is set to zero by default, which means evaluation will
                be run in the trainer process (only if evaluation_interval is not None).
                If you increase this, it will increase the Ray resource usage of the
                trainer since evaluation workers are created separately from rollout
                workers (used to sample data for training).
            custom_evaluation_function: Customize the evaluation method. This must be a
                function of signature (trainer: Trainer, eval_workers: WorkerSet) ->
                metrics: dict. See the Trainer.evaluate() method to see the default
                implementation. The Trainer guarantees all eval workers have the latest
                policy state before this function is called.
            always_attach_evaluation_results: Make sure the latest available evaluation
                results are always attached to a step result dict. This may be useful
                if Tune or some other meta controller needs access to evaluation metrics
                all the time.

        Returns:
            This updated TrainerConfig object.
        """ # Convert another TrainerConfig into dict.
This updated TrainerConfig object.
This updated TrainerConfig object .
self
evaluation_interval
Optional[int]
Evaluate with every `evaluation_interval` training
iterations. The evaluation stats will be reported under the "evaluation"
metric key. Note that for Ape-X metrics are already only reported for
the lowest epsilon workers (least random workers).
Set to None (or 0) for no evaluation.
Evaluate with every ` evaluation_interval ` training iterations . The evaluation stats will be reported under the " evaluation " metric key . Note that for Ape - X metrics are already only reported for the lowest epsilon workers ( least random workers ) . Set to None ( or 0 ) for no evaluation .
evaluation_duration
Optional[int]
Duration for which to run evaluation each
`evaluation_interval`. The unit for the duration can be set via
`evaluation_duration_unit` to either "episodes" (default) or
"timesteps". If using multiple evaluation workers
(evaluation_num_workers > 1), the load to run will be split amongst
these.
If the value is "auto":
For `evaluation_parallel_to_training=True`: Will run as many
episodes/timesteps that fit into the (parallel) training step.
For `evaluation_parallel_to_training=False`: Error.
Duration for which to run evaluation each ` evaluation_interval ` . The unit for the duration can be set via ` evaluation_duration_unit ` to either " episodes " ( default ) or " timesteps " . If using multiple evaluation workers ( evaluation_num_workers > 1 ) the load to run will be split amongst these . If the value is " auto " : For ` evaluation_parallel_to_training = True ` : Will run as many episodes / timesteps that fit into the ( parallel ) training step . For ` evaluation_parallel_to_training = False ` : Error .
evaluation_duration_unit
Optional[str]
The unit, with which to count the evaluation
duration. Either "episodes" (default) or "timesteps".
The unit with which to count the evaluation duration . Either " episodes " ( default ) or " timesteps " .
evaluation_parallel_to_training
Optional[bool]
Whether to run evaluation in parallel to
a Trainer.train() call using threading. Default=False.
E.g. evaluation_interval=2 -> For every other training iteration,
the Trainer.train() and Trainer.evaluate() calls run in parallel.
Note: This is experimental. Possible pitfalls could be race conditions
for weight synching at the beginning of the evaluation loop.
Whether to run evaluation in parallel to a Trainer . train () call using threading . Default = False . E . g . evaluation_interval = 2 - > For every other training iteration the Trainer . train () and Trainer . evaluate () calls run in parallel . Note : This is experimental . Possible pitfalls could be race conditions for weight synching at the beginning of the evaluation loop .
evaluation_config
Optional[
            Union["TrainerConfig", PartialTrainerConfigDict]
        ]
Typical usage is to pass extra args to evaluation env
creator and to disable exploration by computing deterministic actions.
IMPORTANT NOTE: Policy gradient algorithms are able to find the optimal
policy, even if this is a stochastic one. Setting "explore=False" here
will result in the evaluation workers not using this optimal policy!
Typical usage is to pass extra args to evaluation env creator and to disable exploration by computing deterministic actions . IMPORTANT NOTE : Policy gradient algorithms are able to find the optimal policy even if this is a stochastic one . Setting " explore = False " here will result in the evaluation workers not using this optimal policy!
evaluation_num_workers
Optional[int]
Number of parallel workers to use for evaluation.
Note that this is set to zero by default, which means evaluation will
be run in the trainer process (only if evaluation_interval is not None).
If you increase this, it will increase the Ray resource usage of the
trainer since evaluation workers are created separately from rollout
workers (used to sample data for training).
Number of parallel workers to use for evaluation . Note that this is set to zero by default which means evaluation will be run in the trainer process ( only if evaluation_interval is not None ) . If you increase this it will increase the Ray resource usage of the trainer since evaluation workers are created separately from rollout workers ( used to sample data for training ) .
custom_evaluation_function
Optional[Callable]
Customize the evaluation method. This must be a
function of signature (trainer: Trainer, eval_workers: WorkerSet) ->
metrics: dict. See the Trainer.evaluate() method to see the default
implementation. The Trainer guarantees all eval workers have the latest
policy state before this function is called.
Customize the evaluation method . This must be a function of signature ( trainer : Trainer eval_workers : WorkerSet ) - > metrics : dict . See the Trainer . evaluate () method to see the default implementation . The Trainer guarantees all eval workers have the latest policy state before this function is called .
always_attach_evaluation_results
Optional[bool]
Make sure the latest available evaluation
results are always attached to a step result dict. This may be useful
if Tune or some other meta controller needs access to evaluation metrics
all the time.
Make sure the latest available evaluation results are always attached to a step result dict . This may be useful if Tune or some other meta controller needs access to evaluation metrics all the time .