rofunc.learning.RofuncRL.processors.standard_scaler#
1. Module Contents#
1.1. Classes#
1.2. Functions#
1.3. API#
- class rofunc.learning.RofuncRL.processors.standard_scaler.RunningStandardScaler(size: Union[int, Tuple[int], gym.Space, gymnasium.Space], epsilon: float = 1e-08, clip_threshold: float = 5.0, device: Optional[Union[str, torch.device]] = None)[source]#
Bases:
torch.nn.Module- forward(x: torch.Tensor, train: bool = False, inverse: bool = False, no_grad: bool = True) torch.Tensor[source]#
Forward pass of the standardizer
Example:
>>> x = torch.rand(3, 2, device="cuda:0") >>> running_standard_scaler(x) tensor([[0.6933, 0.1905], [0.3806, 0.3162], [0.1140, 0.0272]], device='cuda:0') >>> running_standard_scaler(x, train=True) tensor([[ 0.8681, -0.6731], [ 0.0560, -0.3684], [-0.6360, -1.0690]], device='cuda:0') >>> running_standard_scaler(x, inverse=True) tensor([[0.6260, 0.5468], [0.5056, 0.5987], [0.4029, 0.4795]], device='cuda:0')
- Parameters:
x (torch.Tensor) – Input tensor
train (bool, optional) – Whether to train the standardizer (default:
False)inverse (bool, optional) – Whether to inverse the standardizer to scale back the data (default:
False)no_grad (bool, optional) – Whether to disable the gradient computation (default:
True)