evorl.evaluators

Package Contents

Classes

BraxEvaluator

Mutli-objective evaluator for Brax environments.

EpisodeCollector

Evaluate and return eval metrics and episodic trajectory.

EpisodeObsCollector

Streamlined episode collector for observation only.

Evaluator

Evaluate the agent in the environments.

API

class evorl.evaluators.BraxEvaluator[source]

Bases: evorl.evaluators.evaluator.Evaluator

Mutli-objective evaluator for Brax environments.

Variables:

metric_names – The names of the metrics to evaluate, default is (“reward”, “episode_lengths”)

evaluate(agent_state: chex.ArrayTree, key: chex.PRNGKey, num_episodes: int) chex.ArrayTree[source]
metric_names: tuple[str]

‘pytree_field(…)’

class evorl.evaluators.EpisodeCollector[source]

Bases: evorl.types.PyTreeNode

Evaluate and return eval metrics and episodic trajectory.

EpisodeCollector is similar as Evaluator, but it also returns the trajectories. When evaluating the agent, call rollout().

Variables:
  • env – Vectorized environment w/o autoreset.

  • action_fn – The agent action function.

  • max_episode_steps – The maximum number of steps in an episode.

  • env_extra_fields – The extra fields to collect from the environment.

  • discount – The discount factor.

action_fn: evorl.agent.AgentActionFn

None

discount: float

1.0

env: evorl.envs.Env

None

env_extra_fields: collections.abc.Sequence[str]

()

max_episode_steps: int

‘pytree_field(…)’

rollout(agent_state, key: chex.PRNGKey, num_episodes: int) tuple[evorl.metrics.EvaluateMetric, evorl.sample_batch.SampleBatch][source]
rollout_fn: evorl.rollout.RolloutFn

‘pytree_field(…)’

class evorl.evaluators.EpisodeObsCollector[source]

Bases: evorl.evaluators.episode_collector.EpisodeCollector

Streamlined episode collector for observation only.

rollout_fn: evorl.evaluators.episode_collector.RolloutFn

‘pytree_field(…)’

class evorl.evaluators.Evaluator[source]

Bases: evorl.types.PyTreeNode

Evaluate the agent in the environments.

Variables:
  • env – Vectorized environment w/o autoreset.

  • action_fn – The agent action function.

  • max_episode_steps – The maximum number of steps in an episode.

  • discount – The discount factor.

action_fn: evorl.agent.AgentActionFn

‘pytree_field(…)’

discount: float

‘pytree_field(…)’

env: evorl.envs.Env

‘pytree_field(…)’

evaluate(agent_state: evorl.agent.AgentState, key: chex.PRNGKey, num_episodes: int) evorl.metrics.EvaluateMetric[source]

Evaluate the agent based on its state.

Parameters:
  • agent_state – The state of the agent.

  • key – The PRNG key.

  • num_episodes – The number of episodes to evaluate.

Returns:

EvaluateMetric(episode_returns, episode_lengths).

max_episode_steps: int

‘pytree_field(…)’