NETT
- class nett.NETT(brain: nett.Brain, body: nett.Body, environment: nett.Environment)
The NETT class is the main class for training, testing, and analyzing brains in environments.
- Parameters:
brain (Brain) – The brain to be trained and tested.
body (Body) – The body to be used for training and testing the brain.
environment (Environment) – The environment in which the brain is to be trained and tested.
Example
>>> from nett import NETT >>> # create a brain, body, and environment >>> benchmarks = NETT(brain, body, environment)
- static analyze(config: str, run_dir: str | Path, output_dir: str | Path | None = None, ep_bucket: int = 100, num_episodes: int = 1000, bar_order: str | list[int] = 'default', color_bars: bool = True) None
Analyze the results of a run.
This method is a static method and does not require an instance of the NETT class to be called.
- Parameters:
config (str) – The configuration of the experiment to be analyzed. It can be “parsing”, “binding”, or “viewinvariant”.
run_dir (str | Path) – The directory where the run results are stored.
output_dir (str | Path, optional) – The directory where the analysis results will be stored. If None, the analysis results will be stored in the run directory.
ep_bucket (int, optional) – The number of episodes to be grouped together for analysis.
num_episodes (int, optional) – The number of episodes to be analyzed.
bar_order (str | list[int], optional) – The order in which the bars are to be displayed in the analysis plots. Default is “default”. Can be “default”, “asc”, “desc”, or a list of bar numbers (e.g. [3,1,2,4]).
color_bars (bool, optional) – Whether to color the bars in the analysis plots by condition. Default is True.
- Returns:
None
Example
>>> nett.analyze(run_dir="./test_run", output_dir="./results") # benchmarks is an instance of NETT
- launch_jobs(jobs: list[Job], wait: bool, waitlist: list[Job] = []) dict[Future, Job]
Launch the jobs in the job sheet.
- Parameters:
jobs (list[Job]) – The jobs to be launched.
waitlist (list[Job], optional) – The jobs that are to be queued until memory is available.
- Returns:
A dictionary of futures corresponding to the jobs that were launched from them.
- Return type:
dict[Future, Job]
- run(output_dir: Path | str, num_brains: int = 1, mode: str = 'full', train_eps: int = 1000, test_eps: int = 20, batch_mode: bool = True, device_type: str = 'cuda', devices: list[int] | int = -1, description: str | None = None, job_memory: int = 4, buffer: float = 1.2, steps_per_episode: int = 1000, conditions: list[str] | None = None, verbosity: int = 1, run_id: str = '', synchronous=False, save_checkpoints: bool = False, checkpoint_freq: int = 30000) list[Future]
Run the training and testing of the brains in the environment.
- Parameters:
output_dir (Path | str) – The directory where the run results will be stored.
num_brains (int, optional) – The number of brains to be trained and tested. Defaults to 1.
mode (str, optional) – The mode in which the brains are to be trained and tested. It can be “train”, “test”, or “full”. Defaults to “full”.
train_eps (int, optional) – The number of episodes the brains are to be trained for. Defaults to 1000.
test_eps (int, optional) – The number of episodes the brains are to be tested for. Defaults to 20.
batch_mode (bool, optional) – Whether to run in batch mode, which will not display Unity windows. Good for headless servers. Defaults to True.
device_type (str, optional) – The type of device to be used for training and testing. It can only be “cuda” currently. Defaults to “cuda”.
devices (list[int] | int, optional) – The list of devices to be used for training and testing. If -1, all available devices will be used. Defaults to -1.
description (str, optional) – A description of the run. Defaults to None.
job_memory (int, optional) – The memory allocated, in Gigabytes, for a single job. Defaults to 4.
buffer (float, optional) – The buffer for memory allocation. Defaults to 1.2.
steps_per_episode (int, optional) – The number of steps per episode. Defaults to 1000.
verbosity (int, optional) – The verbosity level of the run. Defaults to 1.
run_id (str, optional) – The run ID. Defaults to ‘’.
synchronous (bool, optional) – Whether to wait for all jobs to end rather than return a Promise. Defaults to False.
save_checkpoints (bool, optional) – Whether to save checkpoints during training. Defaults to False.
checkpoint_freq (int, optional) – The frequency at which checkpoints are saved. Defaults to 30_000.
- Returns:
A list of futures representing the jobs that have been launched.
- Return type:
list[Future]
Example
>>> job_sheet = benchmarks.run(output_dir="./test_run", num_brains=2, train_eps=100, test_eps=10) # benchmarks is an instance of NETT
- status(job_sheet: dict[Future, Job]) DataFrame
Get the status of the jobs in the job sheet.
- Parameters:
job_sheet (dict[Future, Job]) – The job sheet returned by the .launch_jobs() method.
- Returns:
A dataframe containing the status of the jobs in the job sheet.
- Return type:
pd.DataFrame
Example
>>> status = benchmarks.status(job_sheet) >>> # benchmarks is an instance of NETT, job_sheet is the job sheet returned by the .run() method
- summary() None
Generate a toml file and save it to the run directory.