Elementwise decoder

Summary: Tensorf does relu or softmax after the density grid. This diff adds the ability to replicate that.

Reviewed By: bottler

Differential Revision: D40023228

fbshipit-source-id: 9f19868cd68460af98ab6e61c7f708158c26dc08
This commit is contained in:
Darijan Gudelj
2022-10-13 05:59:22 -07:00
committed by Facebook GitHub Bot
parent a607dd063e
commit 76cddd90be
2 changed files with 31 additions and 37 deletions

View File

@@ -1,34 +0,0 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
import unittest
import torch
from pytorch3d.implicitron.models.implicit_function.decoding_functions import (
IdentityDecoder,
MLPDecoder,
)
from pytorch3d.implicitron.tools.config import expand_args_fields
from tests.common_testing import TestCaseMixin
class TestVoxelGrids(TestCaseMixin, unittest.TestCase):
def setUp(self):
torch.manual_seed(42)
expand_args_fields(IdentityDecoder)
expand_args_fields(MLPDecoder)
def test_identity_function(self, in_shape=(33, 4, 1), n_tests=2):
"""
Test that identity function returns its input
"""
func = IdentityDecoder()
for _ in range(n_tests):
_in = torch.randn(in_shape)
assert torch.allclose(func(_in), _in)