Common module

baconian.common

class baconian.common.sampler.sampler.Sampler

Sampler module that handle the sampling procedure for training/testing of the agent.

static sample(env: baconian.core.core.Env, agent, sample_count: int, sample_type='transition', reset_at_start=None) -> (<class 'baconian.common.sampler.sample_data.TransitionData'>, <class 'baconian.common.sampler.sample_data.TrajectoryData'>)

a static method of sample function

Parameters:
  • env – environment object to sample from.
  • agent – agent object to offer the sampling policy
  • in_which_status – a string, “TEST” or “TRAIN” indicate this sample is used for training or testing (evaluation)
  • sample_count – number of samples. If the sample_type == “transition”, then this value means the number of transitions, usually for off-policy method like DQN, DDPG. If the sample_type == “trajectory”, then this value means the numbers of trajectories.
  • sample_type – a string, “transition” or “trajectory”.
  • reset_at_start – A bool, if True, will reset the environment at the beginning, if False, continue sampling based on previous state (this is useful for certain tasks that you need to preserve previous state to reach the terminal goal state). If None, for sample_type == “transition”, it will set to False, for sample_type == “trajectory”, it will set to True.
Returns:

SampleData object.