![]() ![]() """ # Whether to allow unknown top-level config keys. The most important API methods a Algorithm exposes are `train()`, `evaluate()`, `save()` and `restore()`. You can find the different built-in algorithms' `training_step()` methods in their respective main. This allows you to override the `training_step` method to implement your own algorithm logic. You can write your own Algorithm classes by sub-classing from `Algorithm` or any of its built-in sub-classes. The exact synchronization logic depends on the specific algorithm used, but this usually happens from local worker to all remote workers and after each training update. Policies are synchronized automatically from time to time using ray.remote calls. Each worker (remotes or local) contains a PolicyMap, which itself may contain either one policy for single-agent training or one or more policies for multi-agent training. Instead, always access them via all the foreach APIs with assigned IDs of the underlying workers. As a result, Algorithm should never access the underlying actor handles directly. It tracks health states for all the managed remote worker actors. A WorkerSet is normally composed of a single local worker (_worker()), used to compute and apply learning updates, and optionally one or more remote workers used to generate environment samples in parallel. Algorithms contain a WorkerSet under `self.workers`. class Algorithm ( Trainable, AlgorithmBase ): """An RLlib algorithm responsible for optimizing one or more Policies. num_gpus_per_learner_worker : learner_bundles = ", error = True, ) def with_common_config ( * args, ** kwargs ): pass Returns: A list of resource bundles for the learner workers. ) from _ops import synchronous_parallel_sample from _ops import multi_gpu_train_one_step, train_one_step from import get_dataset_and_shards from import ( OffPolicyEstimator, ImportanceSampling, WeightedImportanceSampling, DirectMethod, DoublyRobust, ) from _evaluator import OfflineEvaluator from import Policy from _batch import DEFAULT_POLICY_ID, SampleBatch, concat_samples from import deep_update, FilterManager from import ( DeveloperAPI, ExperimentalAPI, OverrideToImplementCustomLogic, OverrideToImplementCustomLogic_CallToSuperRecommended, PublicAPI, override, ) from import ( CHECKPOINT_VERSION, CHECKPOINT_VERSION_LEARNER, get_checkpoint_info, try_import_msgpack, ) from import update_global_seed_if_necessary from import ( DEPRECATED_VALUE, Deprecated, deprecation_warning, ) from import ERR_MSG_INVALID_ENV_DESCRIPTOR, EnvError from import try_import_tf from _config import from_config from import ( NUM_AGENT_STEPS_SAMPLED, NUM_AGENT_STEPS_SAMPLED_THIS_ITER, NUM_AGENT_STEPS_TRAINED, NUM_ENV_STEPS_SAMPLED, NUM_ENV_STEPS_SAMPLED_THIS_ITER, NUM_ENV_STEPS_TRAINED, SYNCH_WORKER_WEIGHTS_TIMER, TRAINING_ITERATION_TIMER, SAMPLE_TIMER, ) from .learner_info import LEARNER_INFO from import validate_policy_id from _buffers import MultiAgentReplayBuffer, ReplayBuffer from import deserialize_type, NOT_SERIALIZABLE from import space_utils from import ( AgentConnectorDataType, AgentID, AlgorithmConfigDict, EnvCreator, EnvInfoDict, EnvType, EpisodeID, PartialAlgorithmConfigDict, PolicyID, PolicyState, ResultDict, SampleBatchType, TensorStructType, TensorType, ) from _groups import PlacementGroupFactory from import ExportFormat from import Logger, UnifiedLogger from import ENV_CREATOR, _global_registry from import Resources from import DEFAULT_RESULTS_DIR from import Trainable from ray.util import log_once from import _Timer from import get_trainable_cls try : from import AlgorithmBase except ImportError : class AlgorithmBase : def _get_learner_bundles ( cf : AlgorithmConfig ) -> List ]: """Selects the right resource bundles for learner workers based off of cf. From collections import defaultdict import concurrent import copy from datetime import datetime import functools import gymnasium as gym import importlib import json import logging import numpy as np import os from packaging import version import pkg_resources import re import tempfile import time import tree # pip install dm_tree from typing import ( Callable, Container, DefaultDict, Dict, List, Optional, Set, Tuple, Type, Union, ) import ray from ray._lib import TagKey, record_extra_usage_tag from ray.actor import ActorHandle from import Checkpoint import ray.cloudpickle as pickle from _config import AlgorithmConfig from import ALGORITHMS_CLASS_TO_NAME as ALL_ALGORITHMS from .obs_preproc import ObsPreprocessorConnector from _module.rl_module import SingleAgentRLModuleSpec from _context import EnvContext from import _gym_env_creator from import Episode from import ( collect_episodes, collect_metrics, summarize_episodes, ) from _worker import RolloutWorker from _set import WorkerSet from import ( STEPS_TRAINED_THIS_ITER_COUNTER, # TODO: Backward compatibility. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |