trinity.algorithm.sample_strategy package#

Submodules#

Module contents#

class trinity.algorithm.sample_strategy.SampleStrategy(buffer_config: BufferConfig, **kwargs)[source]#

Bases: ABC

__init__(buffer_config: BufferConfig, **kwargs) None[source]#
set_model_version_metric(exp_list: List[Experience], metrics: Dict)[source]#
abstract async sample(step: int) Tuple[Experiences, Dict, List][source]#

Sample data from buffer.

Parameters:

step (int) – The step number of current step.

Returns:

The sampled Experiences data. Dict: Metrics for logging. List: Representative data for logging.

Return type:

Experiences

abstract classmethod default_args() dict[source]#

Get the default arguments of the sample strategy.

abstract state_dict() dict[source]#

Get the state dict of the sample strategy.

abstract load_state_dict(state_dict: dict) None[source]#

Load the state dict of the sample strategy.

class trinity.algorithm.sample_strategy.DefaultSampleStrategy(buffer_config: BufferConfig, **kwargs)[source]#

Bases: SampleStrategy

__init__(buffer_config: BufferConfig, **kwargs)[source]#
async sample(step: int, **kwargs) Tuple[Experiences, Dict, List][source]#

Sample data from buffer.

Parameters:

step (int) – The step number of current step.

Returns:

The sampled Experiences data. Dict: Metrics for logging. List: Representative data for logging.

Return type:

Experiences

classmethod default_args() dict[source]#

Get the default arguments of the sample strategy.

state_dict() dict[source]#

Get the state dict of the sample strategy.

load_state_dict(state_dict: dict) None[source]#

Load the state dict of the sample strategy.

class trinity.algorithm.sample_strategy.WarmupSampleStrategy(buffer_config: BufferConfig, **kwargs)[source]#

Bases: DefaultSampleStrategy

The warmup sample strategy. Deprecated, keep this class for backward compatibility only. Please use DefaultSampleStrategy instead.

__init__(buffer_config: BufferConfig, **kwargs)[source]#
class trinity.algorithm.sample_strategy.MixSampleStrategy(buffer_config: BufferConfig, **kwargs)[source]#

Bases: SampleStrategy

The default sample strategy.

__init__(buffer_config: BufferConfig, **kwargs)[source]#
async sample(step: int) Tuple[Experiences, Dict, List][source]#

Sample data from buffer.

Parameters:

step (int) – The step number of current step.

Returns:

The sampled Experiences data. Dict: Metrics for logging. List: Representative data for logging.

Return type:

Experiences

classmethod default_args() Dict[source]#

Get the default arguments of the sample strategy.

state_dict() dict[source]#

Get the state dict of the sample strategy.

load_state_dict(state_dict: dict) None[source]#

Load the state dict of the sample strategy.