Add KPlanesEncoding encoding (#1658)

Co-authored-by: gmeanti <giacomo.meanti@gmail.com>
This commit is contained in:
Giodiroandgmeanti authored and GitHub committed 2023-03-24 08:18:57 -07:00
1 parent e6ee0292e0
commit 78fbe6513e
2 files changed
+109 -2

No files matched your search

+26
View File
@@ -171,6 +171,32 @@ def test_tensor_hash_encoder():
assert encoded.shape == (10, out_dim)
def test_kplane_encoder():
"""Test K-Planes encoder"""
out_dim = 8
encoder = encodings.KPlanesEncoding(
resolution=(32, 32, 32, 16),
num_components=out_dim,
reduce="product",
)
assert encoder.get_out_dim() == out_dim
in_tensor = torch.randn((10, 4))
encoded = encoder(in_tensor)
assert encoded.shape == (10, out_dim)
encoder = encodings.KPlanesEncoding(
resolution=(32, 32, 32),
num_components=out_dim,
reduce="product",
)
in_tensor = torch.randn((10, 3))
encoded = encoder(in_tensor)
assert encoded.shape == (10, out_dim)
if __name__ == "__main__":
test_scaling_and_offset()
test_nerf_encoder()