-
Notifications
You must be signed in to change notification settings - Fork 0
/
model.py
42 lines (37 loc) · 1.09 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
36
37
38
39
40
41
42
import torch
import torch.nn as nn
class FFN(torch.nn.Module):
def __init__(self, input_dim=2):
super(FFN, self).__init__()
### TODO: define and initialize some layers with weights
self.layers = nn.Sequential(
nn.Linear(input_dim, 1024),
nn.ReLU(),
nn.Linear(1024, 512),
nn.ReLU(),
nn.Linear(512, 256),
nn.ReLU(),
nn.Linear(256, 3),
)
def forward(self, coord):
out = self.layers(coord)
return out
class Sin(torch.nn.Module):
def forward(self, x):
return torch.sin(x)
class FFN_Sin(torch.nn.Module):
def __init__(self, input_dim=2):
super(FFN_Sin, self).__init__()
### TODO: define and initialize some layers with weights
self.layers = nn.Sequential(
nn.Linear(input_dim, 1024),
Sin(),
nn.Linear(1024, 512),
Sin(),
nn.Linear(512, 256),
Sin(),
nn.Linear(256, 3),
)
def forward(self, coord):
out = self.layers(coord)
return out