skrl icon indicating copy to clipboard operation
skrl copied to clipboard

Random action only samples from the first action space dimension

Open nikolaradulov opened this issue 1 year ago • 0 comments

Description

Random actions are done by taking the low and high values of the first dimension on the action space a,d then uniformly sampling from [low, high] for each dimension of an action.

   self._random_distribution = torch.distributions.uniform.Uniform(
                    low=torch.tensor(self.action_space.low[0], device=self.device, dtype=torch.float32),
                    high=torch.tensor(self.action_space.high[0], device=self.device, dtype=torch.float32))

The issue is that if i have the following action space for example gym.Box(low=[-5, -3], high=[5,3]) any sampled action[1] will be in [-5,5] instead of [-3,3]

SOLUTION IS:

self._random_distribution = torch.distributions.uniform.Uniform(
                  low=torch.tensor(self.action_space.low, device=self.device, dtype=torch.float32),
                  high=torch.tensor(self.action_space.high, device=self.device, dtype=torch.float32))

What skrl version are you using?

1.0.0

What ML framework/library version are you using?

pytorch

Additional system information

No response

nikolaradulov avatar Jun 20 '24 22:06 nikolaradulov