Skip to content

Experiment

A class to run an experiment with a given agent and environment.

Parameters:

Name Type Description Default
name str

The name of the experiment.

required
agent Agent

The agent to use in the experiment.

required
env Environment

The environment to use in the experiment.

required
env_id str

The ID of the environment.

''
seeds Tuple[int, ...]

The seeds to use in the experiment.

(0)
group str

The group to use in the experiment.

''

Attributes:

Name Type Description
name str

The name of the experiment.

agent Agent

The agent to use in the experiment.

env Environment

The environment to use in the experiment.

env_id str

The ID of the environment.

seeds Tuple[int, ...]

The seeds to use in the experiment.

group str

The group to use in the experiment.

Default function to run the experiment. This function compiles the training function, trains the agent, and logs the results.

Parameters:

Name Type Description Default
do_log bool

Whether to log the results to wandb.

True

Warning

Logging to wandb is usually much slower than training the agent itself. The time is linear in the number of seeds.

Returns:

Name Type Description
Tuple

A tuple containing the final training state and the logs.

Function to run a hyperparameter search for the experiment. This function samples hyperparameters from the given distributions, trains the agent, and logs the results.

Parameters:

Name Type Description Default
hparams_distr Dict[str, Distribution]

A dictionary of hyperparameter distributions. The keys are the hyperparameter names, which must exist in self.agent.hparams, and the values are the corresponding distributions.

required
pop_size int

The number of hyperparameter sets to sample.

required

Returns:

Name Type Description
Tuple

A tuple containing the final training states and the logs, batched over the hyperparameter sets.