update docstrings and random cleanups (#387)

* fixing docstrings and small nits; up to fileds

* finished adding and fixing docstrings
This commit is contained in:
evonneng authored and GitHub committed 2022-09-10 23:09:44 -07:00
1 parent bd5967461d
commit d50c71ac43
52 files changed
+846 -646

No files matched your search

+6 -11
View File
@@ -26,8 +26,8 @@ class FieldModule(nn.Module):
"""Field modules that can be combined to store and compute the fields.
Args:
in_dim (int, optional): Input dimension to module.
out_dim (int, optional): Ouput dimension to module.
in_dim: Input dimension to module.
out_dim: Ouput dimension to module.
"""
def __init__(self, in_dim: Optional[int] = None, out_dim: Optional[int] = None) -> None:
@@ -43,18 +43,14 @@ class FieldModule(nn.Module):
"""Sets input dimension of encoding
Args:
in_dim (int): input dimension
in_dim: input dimension
"""
if in_dim <= 0:
raise ValueError("Input dimension should be greater than zero")
self.in_dim = in_dim
def get_out_dim(self) -> int:
"""Calculates output dimension of encoding.
Returns:
int: output dimension
"""
"""Calculates output dimension of encoding."""
if self.out_dim is None:
raise ValueError("Output dimension has not been set")
return self.out_dim
@@ -62,10 +58,9 @@ class FieldModule(nn.Module):
@abstractmethod
def forward(self, in_tensor: TensorType["bs":..., "input_dim"]) -> TensorType["bs":..., "output_dim"]:
"""
Returns processed tensor
Args:
in_tensor: Input tensor to process
Returns:
Processed tensor
"""
raise NotImplementedError
+7 -3
View File
@@ -28,8 +28,8 @@ class Embedding(FieldModule):
# TODO: add different types of initializations
Args:
in_dim (int): Number of embeddings
out_dim (int): Dimension of the embedding vectors
in_dim: Number of embeddings
out_dim: Dimension of the embedding vectors
"""
def __init__(self, in_dim: int, out_dim: int) -> None:
@@ -42,5 +42,9 @@ class Embedding(FieldModule):
self.embedding = torch.nn.Embedding(self.in_dim, self.out_dim)
def forward(self, in_tensor: TensorType[..., "input_dim"]) -> TensorType[..., "output_dim"]:
"""Call forward"""
"""Call forward
Args:
in_tensor: input tensor to process
"""
return self.embedding(in_tensor)
+6 -4
View File
@@ -43,6 +43,11 @@ class Encoding(FieldModule):
@abstractmethod
def forward(self, in_tensor: TensorType["bs":..., "input_dim"]) -> TensorType["bs":..., "output_dim"]:
"""Call forward and returns and processed tensor
Args:
in_tensor: the input tensor to process
"""
raise NotImplementedError
@@ -243,13 +248,10 @@ class HashEncoding(Encoding):
return self.num_levels * self.features_per_level
def hash_fn(self, in_tensor: TensorType["bs":..., "num_levels", 3]) -> TensorType["bs":..., "num_levels"]:
"""Hash tensor using method described in Instant-NGP
"""Returns hash tensor using method described in Instant-NGP
Args:
in_tensor: Tensor to be hashed
Returns:
Hashed tensor
"""
# min_val = torch.min(in_tensor)