mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-11-19 14:23:57 +08:00
update docstrings and random cleanups (#387)
* fixing docstrings and small nits; up to fileds * finished adding and fixing docstrings
This commit is contained in:
1 parent
bd5967461d
commit
d50c71ac43
52 files changed
+846
-646
No files matched your search
@@ -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
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
|
||||
Reference in new issue
Block a user