-
Notifications
You must be signed in to change notification settings - Fork 11
/
model.py
35 lines (29 loc) · 1.29 KB
/
model.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import torch
class Neural_Prior(torch.nn.Module):
def __init__(self, dim_x=3, filter_size=128, act_fn='relu', layer_size=8):
super().__init__()
self.layer_size = layer_size
self.nn_layers = torch.nn.ModuleList([])
# input layer (default: xyz -> 128)
if layer_size >= 1:
self.nn_layers.append(torch.nn.Sequential(torch.nn.Linear(dim_x, filter_size)))
if act_fn == 'relu':
self.nn_layers.append(torch.nn.ReLU())
elif act_fn == 'sigmoid':
self.nn_layers.append(torch.nn.Sigmoid())
for _ in range(layer_size-1):
self.nn_layers.append(torch.nn.Sequential(torch.nn.Linear(filter_size, filter_size)))
if act_fn == 'relu':
self.nn_layers.append(torch.nn.ReLU())
elif act_fn == 'sigmoid':
self.nn_layers.append(torch.nn.Sigmoid())
self.nn_layers.append(torch.nn.Linear(filter_size, dim_x))
else:
self.nn_layers.append(torch.nn.Sequential(torch.nn.Linear(dim_x, dim_x)))
def forward(self, x):
""" points -> features
[B, N, 3] -> [B, K]
"""
for layer in self.nn_layers:
x = layer(x)
return x