Functional

rff.functional.basic_encoding(v: torch.Tensor) torch.Tensor

Computes \(\gamma(\mathbf{v}) = (\cos{2 \pi \mathbf{v}} , \sin{2 \pi \mathbf{v}})\)

Parameters

v (Tensor) – input tensor of shape \((N, *, \text{input_size})\)

Returns

mapped tensor of shape \((N, *, 2 \cdot \text{input_size})\)

Return type

Tensor

See BasicEncoding for more details.

rff.functional.gaussian_encoding(v: torch.Tensor, b: torch.Tensor) torch.Tensor

Computes \(\gamma(\mathbf{v}) = (\cos{2 \pi \mathbf{B} \mathbf{v}} , \sin{2 \pi \mathbf{B} \mathbf{v}})\)

Parameters
  • v (Tensor) – input tensor of shape \((N, *, \text{input_size})\)

  • b (Tensor) – projection matrix of shape \((\text{encoded_layer_size}, \text{input_size})\)

Returns

mapped tensor of shape \((N, *, 2 \cdot \text{encoded_layer_size})\)

Return type

Tensor

See GaussianEncoding for more details.

rff.functional.positional_encoding(v: torch.Tensor, sigma: float, m: int) torch.Tensor
gamma(mathbf{v}) = (dots, cos{2 pi sigma^{(j/m)} mathbf{v}} , sin{2 pi sigma^{(j/m)} mathbf{v}}, dots)

where \(j \in \{0, \dots, m-1\}\)

Parameters
  • v (Tensor) – input tensor of shape \((N, *, \text{input_size})\)

  • sigma (float) – constant chosen based upon the domain of v

  • m (int) – [description]

Returns

mapped tensor of shape \((N, *, 2 \cdot m \cdot \text{input_size})\)

Return type

Tensor

See PositionalEncoding for more details.

rff.functional.sample_b(sigma: float, size: tuple) torch.Tensor

Matrix of size size sampled from from \(\mathcal{N}(0, \sigma^2)\)

Parameters
  • sigma (float) – standard deviation

  • size (tuple) – size of the matrix sampled

See GaussianEncoding for more details