class_docstr: Sine-cosine positional encoder for input points.
docstr: Initialize positional encoder.
  
  Args:
      num_dims: Number of input dimensions (channels): int
      num_freqs: Number of frequency bands for encoding span: int
      log_space: Whether frequency sampling should be log spaced: bool
docstr_tok: ["Initialize","positional","encoder",".","Args",":","num_dims",":","Number","of","input","dimensions","(","channels",")",":","int","num_freqs",":","Number","of","frequency","bands","for","encoding","span",":","int","log_space",":","Whether","frequency","sampling","should","be","log","spaced",":","bool"]
code: def __init__(
      self, num_dims: int, num_freqs: int, log_space: bool = False
  ) -> None:
      """Initialize positional encoder.
  
      Args:
          num_dims: Number of input dimensions (channels): int
          num_freqs: Number of frequency bands for encoding span: int
          log_space: Whether frequency sampling should be log spaced: bool
      """
      super().__init__()
      self._num_dims = num_dims
      self._embed_fns = [lambda x: x]
  
      # Define frequencies in either linear or log scale
      freq_bands: Tensor
      if log_space:
          freq_bands = 2.0 ** torch.linspace(
              0.0, num_freqs - 1, num_freqs
          )
      else:
          freq_bands = torch.linspace(
              2.0**0.0, 2.0 ** (num_freqs - 1), num_freqs
          )
  
      # Alternate sin and cos
      for freq in freq_bands:
          self._embed_fns.append(partial(_torch_sin, freq=freq))
          self._embed_fns.append(partial(_torch_cos, freq=freq))
  
      self._num_encoded_dims = self._num_dims * len(self._embed_fns)
  
file_path: kornia/kornia/nerf/positional_encoder.py
imports: from functools import partial
  import torch
  from torch import nn
  from kornia.core import Tensor
label_desc: Use image node_id 1 to create a new PositionalEncoder object from inherited base classes: nn with example: obj = PositionalEncoder(num_dims, num_freqs, log_space)