(self, x, scale)
return x_zoomed
Perform forward pass.

        Parameters
        ----------
        x : torch.Tensor
            Tensor of shape `(n_samples, n_channels, lookback, n_assets)`.

        scale : torch.Tensor
            Tensor of shape `(n_samples,)` representing how much to zoom in (`scale < 1`) or
            zoom out (`scale > 1`).

        Returns
        -------
        torch.Tensor
            Tensor of shape `(n_samples, n_channels, lookback, n_assets)` that is a zoomed
            version of the input. Note that the shape is identical to the input.
Perform forward pass.
Perform forward pass .
def forward(self, x, scale):
        """Perform forward pass.

        Parameters
        ----------
        x : torch.Tensor
            Tensor of shape `(n_samples, n_channels, lookback, n_assets)`.

        scale : torch.Tensor
            Tensor of shape `(n_samples,)` representing how much to zoom in (`scale < 1`) or
            zoom out (`scale > 1`).

        Returns
        -------
        torch.Tensor
            Tensor of shape `(n_samples, n_channels, lookback, n_assets)` that is a zoomed
            version of the input. Note that the shape is identical to the input.

        """
        translate = 1 - scale

        theta = torch.stack([torch.tensor([[1, 0, 0],
                                           [0, s, t]]) for s, t in zip(scale, translate)], dim=0)
        theta = theta.to(device=x.device, dtype=x.dtype)

        grid = nn.functional.affine_grid(theta, x.shape, align_corners=True)
        x_zoomed = nn.functional.grid_sample(x,
                                             grid,
                                             mode=self.mode,
                                             padding_mode=self.padding_mode,
                                             align_corners=True,
                                             )

        return x_zoomed
def forward ( self , x , scale ) : translate = 1 - scale theta = torch . stack ( [ torch . tensor ( [ [ 1 , 0 , 0 ] , [ 0 , s , t ] ] ) for s , t in zip ( scale , translate ) ] , dim = 0 ) theta = theta . to ( device = x . device , dtype = x . dtype ) grid = nn . functional . affine_grid ( theta , x . shape , align_corners = True ) x_zoomed = nn . functional . grid_sample ( x , grid , mode = self . mode , padding_mode = self . padding_mode , align_corners = True , ) return x_zoomed