Factor out nerf_field

This commit is contained in:
Matt Tancik committed 2022-05-20 11:58:53 -07:00
1 parent 279df6a9ce
commit 9b63adba01
5 files changed
+140 -126

No files matched your search

+12
View File
@@ -2,6 +2,7 @@
Encoding functions
"""
from abc import abstractmethod
import numpy as np
import torch
import torch.nn.functional as F
@@ -25,6 +26,7 @@ class Encoding(FieldModule):
raise ValueError("Input dimension should be greater than zero")
self.in_dim = in_dim
@abstractmethod
def encode(self, in_tensor: TensorType[..., "input_dim"]) -> TensorType[..., "output_dim"]:
"""Encodes an input tensor.
@@ -41,6 +43,16 @@ class Encoding(FieldModule):
return self.encode(in_tensor)
class Identity(Encoding):
"""Identity encoding (Does not modify input)"""
def get_out_dim(self) -> int:
return self.in_dim
def encode(self, in_tensor: TensorType[..., "input_dim"]) -> TensorType[..., "output_dim"]:
return in_tensor
class ScalingAndOffset(Encoding):
"""Simple scaling and offet to input"""