mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-11-20 06:35:36 +08:00
Merge pull request #24 from ethanweber/tancik/mlp_test
Updated mlp tests
This commit is contained in:
3 files changed
+36
-5
No files matched your search
@@ -17,7 +17,7 @@ class MLP(FieldModule):
|
|||||||
out_dim: int,
|
out_dim: int,
|
||||||
num_layers: int,
|
num_layers: int,
|
||||||
layer_width: int,
|
layer_width: int,
|
||||||
activation: Optional[nn.Module] = None,
|
activation: Optional[nn.Module] = nn.ReLU(),
|
||||||
out_activation: Optional[nn.Module] = None,
|
out_activation: Optional[nn.Module] = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize parameters of mulilayer perceptron.
|
"""Initialize parameters of mulilayer perceptron.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
"""
|
"""
|
||||||
Render Head Tests
|
Field output tests
|
||||||
"""
|
"""
|
||||||
import pytest
|
import pytest
|
||||||
import torch
|
import torch
|
||||||
@@ -9,7 +9,7 @@ from mattport.nerf.field_modules import field_outputs
|
|||||||
|
|
||||||
|
|
||||||
def test_field_output():
|
def test_field_output():
|
||||||
"""Test rgb render head"""
|
"""Test render output"""
|
||||||
in_dim = 6
|
in_dim = 6
|
||||||
out_dim = 4
|
out_dim = 4
|
||||||
activation = nn.ReLU()
|
activation = nn.ReLU()
|
||||||
@@ -26,7 +26,7 @@ def test_field_output():
|
|||||||
assert y.shape[-1] == out_dim
|
assert y.shape[-1] == out_dim
|
||||||
|
|
||||||
|
|
||||||
def test_density_head():
|
def test_density_output():
|
||||||
"""Test rgb output"""
|
"""Test rgb output"""
|
||||||
in_dim = 6
|
in_dim = 6
|
||||||
density_head = field_outputs.DensityFieldOutput(in_dim)
|
density_head = field_outputs.DensityFieldOutput(in_dim)
|
||||||
@@ -41,7 +41,7 @@ def test_density_head():
|
|||||||
assert y.shape[-1] == 1
|
assert y.shape[-1] == 1
|
||||||
|
|
||||||
|
|
||||||
def test_rgb_head():
|
def test_rgb_output():
|
||||||
"""Test rgb output"""
|
"""Test rgb output"""
|
||||||
in_dim = 6
|
in_dim = 6
|
||||||
rgb_head = field_outputs.RGBFieldOutput(in_dim)
|
rgb_head = field_outputs.RGBFieldOutput(in_dim)
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
"""
|
||||||
|
MLP Test
|
||||||
|
"""
|
||||||
|
import torch
|
||||||
|
from torch import nn
|
||||||
|
|
||||||
|
from mattport.nerf.field_modules import MLP
|
||||||
|
|
||||||
|
|
||||||
|
def test_mlp():
|
||||||
|
"""Test mlp"""
|
||||||
|
in_dim = 6
|
||||||
|
out_dim = 10
|
||||||
|
num_layers = 2
|
||||||
|
layer_width = 32
|
||||||
|
out_activation = nn.ReLU()
|
||||||
|
mlp = MLP(
|
||||||
|
in_dim=in_dim, out_dim=out_dim, num_layers=num_layers, layer_width=layer_width, out_activation=out_activation
|
||||||
|
)
|
||||||
|
assert mlp.get_out_dim() == out_dim
|
||||||
|
|
||||||
|
x = torch.ones((9, in_dim))
|
||||||
|
|
||||||
|
mlp.build_nn_modules()
|
||||||
|
y = mlp(x)
|
||||||
|
|
||||||
|
assert y.shape[-1] == out_dim
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
test_mlp()
|
||||||
Reference in new issue
Block a user