prl.transformers package¶
Submodules¶
prl.transformers.action_transformers module¶
-
class
ActionTransformer[source]¶ Bases:
prl.typing.ActionTransformerABC,abc.ABCInterface for raw action (original actions from agent) transformers. Object of this class are used by the classes implementing EnvironmentABC interface. Action transformers can use all episode history from the beginning of the episode up to the moment of transformation.
-
action_space(original_space)[source]¶ Returns: action_space object of class gym.Space, which defines type and shape of transformed action.
Note
If transformed action is from the same action_space as original state, then action_space is None. Information contained within action_space can be important for agents, so it is important to properly define an action_space.
Return type: Space
-
id¶ State transformer UUID
Return type: str
-
transform(action, history)[source]¶ Transforms action into another representation, which must be of the form defined by action_space object. Input action can be in a form of numpy array, list, tuple, int, etc.
Parameters: - action (
ndarray) – Action from the agent - history (
HistoryABC) – History object of an episode
Return type: ndarrayReturns: Transformed action in form defined by the action_space object.
- action (
-
-
class
NoOpActionTransformer[source]¶ Bases:
prl.transformers.action_transformers.ActionTransformerActionTransformer doing nothing
-
action_space(original_space)[source]¶ Returns: action_space object of class gym.Space, which defines type and shape of transformed action.
Note
If transformed action is from the same action_space as original state, then action_space is None. Information contained within action_space can be important for agents, so it is important to properly define an action_space.
Return type: Space
-
id¶ State transformer UUID
-
transform(action, history)[source]¶ Transforms action into another representation, which must be of the form defined by action_space object. Input action can be in a form of numpy array, list, tuple, int, etc.
Parameters: - action (
ndarray) – Action from the agent - history (
HistoryABC) – History object of an episode
Return type: ndarrayReturns: Transformed action in form defined by the action_space object.
- action (
-
prl.transformers.reward_transformers module¶
-
class
NoOpRewardTransformer[source]¶ Bases:
prl.transformers.reward_transformers.RewardTransformerRewardTransformer doing nothing
-
transform(reward, history)[source]¶ Transforms a reward.
Parameters: - reward (
Real) – Raw reward from the wrapped environment - history (
HistoryABC) – History object
Return type: NumberReturns: Transformed reward
- reward (
-
-
class
RewardShiftTransformer(shift)[source]¶ Bases:
prl.transformers.reward_transformers.RewardTransformerRewardTransformer shifting reward by some constant value
-
transform(reward, history)[source]¶ Transforms a reward.
Parameters: - reward (
Real) – Raw reward from the wrapped environment - history (
HistoryABC) – History object
Return type: NumberReturns: Transformed reward
- reward (
-
-
class
RewardTransformer[source]¶ Bases:
prl.typing.RewardTransformerABC,abc.ABCInterface for classes for shaping the raw reward from wrapped environments. Object inherited from this class are used by the Environment class objects. Reward transformers can use all episode history from the beginning of the episode up to the moment of transformation.
-
id¶ Reward transformer UUID
Return type: str
-
transform(reward, history)[source]¶ Transforms a reward.
Parameters: - reward (
Real) – Raw reward from the wrapped environment - history (
HistoryABC) – History object
Return type: RealReturns: Transformed reward
- reward (
-
prl.transformers.state_transformers module¶
-
class
NoOpStateTransformer[source]¶ Bases:
prl.transformers.state_transformers.StateTransformerStateTransformer doing nothing
-
id¶ State transformer UUID
-
transform(state, history)[source]¶ Transforms observed state into another representation, which must be of the form defined by observation_space object. Input state must be in a form of numpy.ndarray.
Parameters: - state (
ndarray) – State from wrapped environment - history (
HistoryABC) – History object
Return type: ndarrayReturns: Transformed state in form defined by the observation_space object.
- state (
-
-
class
PongTransformer(resize_factor=2, crop=True, flatten=False)[source]¶ Bases:
prl.transformers.state_transformers.StateTransformerStateTransformer for Pong atari game
-
id¶ State transformer UUID
-
transform(observation, history)[source]¶ Transforms observed state into another representation, which must be of the form defined by observation_space object. Input state must be in a form of numpy.ndarray.
Parameters: - state – State from wrapped environment
- history (
HistoryABC) – History object
Return type: ndarrayReturns: Transformed state in form defined by the observation_space object.
-
-
class
StateShiftTransformer(shift_tensor)[source]¶ Bases:
prl.transformers.state_transformers.StateTransformerStateTransformer shifting reward by some constant vector
-
id¶ State transformer UUID
-
transform(state, history)[source]¶ Transforms observed state into another representation, which must be of the form defined by observation_space object. Input state must be in a form of numpy.ndarray.
Parameters: - state (
ndarray) – State from wrapped environment - history (
HistoryABC) – History object
Return type: ndarrayReturns: Transformed state in form defined by the observation_space object.
- state (
-
-
class
StateTransformer[source]¶ Bases:
prl.typing.StateTransformerABC,abc.ABCInterface for raw states (original states from wrapped environments) transformers. Object of this class are used by the classes implementing EnvironmentABC interface. State transformers can use all episode history from the beginning of the episode up to the moment of transformation.
-
id¶ State transformer UUID
Return type: str
-
transform(state, history)[source]¶ Transforms observed state into another representation, which must be of the form defined by observation_space object. Input state must be in a form of numpy.ndarray.
Parameters: - state (
ndarray) – State from wrapped environment - history (
HistoryABC) – History object
Return type: ndarrayReturns: Transformed state in form defined by the observation_space object.
- state (
-