Shortcuts

framework.middleware.collector

collector

StepCollector

class ding.framework.middleware.collector.StepCollector(*args, **kwargs)[source]
Overview:

The class of the collector running by steps, including model inference and transition process. Use the __call__ method to execute the whole collection process.

__call__(ctx: OnlineRLContext) None[source]
Overview:

An encapsulation of inference and rollout middleware. Stop when completing the target number of steps.

Input of ctx:
  • env_step (int): The env steps which will increase during collection.

__init__(cfg: EasyDict, policy, env: BaseEnvManager, random_collect_size: int = 0) None[source]
Arguments:
  • cfg (EasyDict): Config.

  • policy (Policy): The policy to be collected.

  • env (BaseEnvManager): The env for the collection, the BaseEnvManager object or its derivatives are supported.

  • random_collect_size (int): The count of samples that will be collected randomly, typically used in initial runs.

EpisodeCollector

class ding.framework.middleware.collector.EpisodeCollector(cfg: EasyDict, policy, env: BaseEnvManager, random_collect_size: int = 0)[source]
Overview:

The class of the collector running by episodes, including model inference and transition process. Use the __call__ method to execute the whole collection process.

__call__(ctx: OnlineRLContext) None[source]
Overview:

An encapsulation of inference and rollout middleware. Stop when completing the target number of episodes.

Input of ctx:
  • env_episode (int): The env env_episode which will increase during collection.

__init__(cfg: EasyDict, policy, env: BaseEnvManager, random_collect_size: int = 0) None[source]
Arguments:
  • cfg (EasyDict): Config.

  • policy (Policy): The policy to be collected.

  • env (BaseEnvManager): The env for the collection, the BaseEnvManager object or its derivatives are supported.

  • random_collect_size (int): The count of samples that will be collected randomly, typically used in initial runs.