INNER CODE UNIT · Python
HashEmbedder
yashbhalgat/HashNeRF-pytorch · hash_encoding.py:10
class HashEmbedder(nn.Module):
def __init__(self, bounding_box, n_levels=16, n_features_per_level=2,\
log2_hashmap_size=19, base_resolution=16, finest_resolution=512):
super(HashEmbedder, self).__init__()
self.bounding_box = bounding_box
self.n_levels = n_levels
self.n_features_per_level = n_features_per_level
self.log2_hashmap_size = log2_hashmap_size
self.base_resolution = torch.tensor(base_resolution)
self.finest_resolution = torch.tensor(finest_resolution)
self.out_dim = self.n_levels * self.n_features_per_level
self.b = torch.exp((torch.log(self.finest_resolution)-torch.log(self.base_resolution))/(n_levels-1))
self.embeddings = nn.ModuleList([nn.Embedding(2**self.log2_hashmap_size, \
self.n_features_per_level) for i in range(n_levels)])
# custom uniform initialization
for i in range(n_levels):