evorl.metrics

Module Contents

Classes

ECTrainMetric

Training metrics for ECWorkflow.

ECWorkflowMetric

Workflow metrics for ECWorkflow.

EvaluateMetric

Evaluation metrics for RLWorkflow.

MetricBase

Base class for all metrics.

MultiObjectiveECWorkflowMetric

Workflow metrics for MultiObjectiveECWorkflow.

TrainMetric

Training metrics for RLWorkflow.

WorkflowMetric

Workflow metrics for RLWorkflow.

Functions

metric_field

Define a metric field in MetricBase.

to_local_dict

API

class evorl.metrics.ECTrainMetric[source]

Bases: evorl.metrics.MetricBase

Training metrics for ECWorkflow.

Variables:
  • objectives – The objective values for current step.

  • ec_metrics – The extra metrics of the training step.

ec_metrics: chex.ArrayTree

None

objectives: chex.Array

None

class evorl.metrics.ECWorkflowMetric[source]

Bases: evorl.metrics.MetricBase

Workflow metrics for ECWorkflow.

Variables:
  • best_objective – The best objective value found so far.

  • sampled_episodes – The total number of sampled episodes from environments..

  • sampled_timesteps_m – The total number of sampled timesteps from environments, measured in millions.

  • iterations – The total number of workflow iterations.

best_objective: chex.Array

None

iterations: chex.Array

‘zeros(…)’

sampled_episodes: chex.Array

‘zeros(…)’

sampled_timesteps_m: chex.Array

‘zeros(…)’

class evorl.metrics.EvaluateMetric[source]

Bases: evorl.metrics.MetricBase

Evaluation metrics for RLWorkflow.

Variables:
  • episode_returns – The return array of evaluation episodes.

  • episode_lengths – The length array of evaluation episodes.

episode_lengths: chex.Array

‘metric_field(…)’

episode_returns: chex.Array

‘metric_field(…)’

class evorl.metrics.MetricBase[source]

Bases: evorl.types.PyTreeData

Base class for all metrics.

all_reduce(dp_axis_name: str | None = None)[source]
to_local_dict()[source]

Convert the dataclass to native python structures recursively.

The data in the metric object will be converted to local data types: list, tuple, dict, NamedTuple, etc. Jax array will be convert to numpy array,

Returns:

A converted dict.

class evorl.metrics.MultiObjectiveECWorkflowMetric[source]

Bases: evorl.metrics.MetricBase

Workflow metrics for MultiObjectiveECWorkflow.

Variables:
  • sampled_episodes – The total number of sampled episodes from environments..

  • sampled_timesteps_m – The total number of sampled timesteps from environments, measured in millions.

  • iterations – The total number of workflow iterations.

iterations: chex.Array

‘zeros(…)’

sampled_episodes: chex.Array

‘zeros(…)’

sampled_timesteps_m: chex.Array

‘zeros(…)’

class evorl.metrics.TrainMetric[source]

Bases: evorl.metrics.MetricBase

Training metrics for RLWorkflow.

Variables:
  • train_episode_return – The return of the training episode.

  • loss – The loss value of the training step.

  • raw_loss_dict – The raw loss dict of the training step.

loss: chex.Array

‘zeros(…)’

raw_loss_dict: evorl.types.LossDict

‘metric_field(…)’

train_episode_return: chex.Array | None

None

class evorl.metrics.WorkflowMetric[source]

Bases: evorl.metrics.MetricBase

Workflow metrics for RLWorkflow.

Variables:
  • sampled_timesteps – The total number of sampled timesteps from environments.

  • iterations – The total number of workflow iterations.

iterations: chex.Array

‘zeros(…)’

sampled_episodes: chex.Array

‘zeros(…)’

sampled_timesteps: chex.Array

‘zeros(…)’

evorl.metrics.metric_field(*, reduce_fn: collections.abc.Callable[[chex.Array, str | None], chex.Array] = None, static=False, **kwargs)[source]

Define a metric field in MetricBase.

Parameters:
  • reduce_fn – A function to reduce the metric value across different devices. For example, jax.mean

  • static – Whether the field is static related to pytree.

Returns:

A dataclass field.

evorl.metrics.to_local_dict(obj, *, dict_factory=dict)[source]