MCPcopy Create free account
hub / github.com/cvlab-epfl/MeshSDF / DeepSDF

Class DeepSDF

lib/models/decoder.py:11–120  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9
10
11class DeepSDF(nn.Module):
12 def __init__(
13 self,
14 latent_size,
15 dims,
16 dropout=None,
17 dropout_prob=0.0,
18 norm_layers=(),
19 latent_in=(),
20 weight_norm=False,
21 xyz_in_all=None,
22 use_tanh=False,
23 latent_dropout=False,
24 positional_encoding = False,
25 fourier_degree = 1
26 ):
27 super(DeepSDF, self).__init__()
28
29 def make_sequence():
30 return []
31 if positional_encoding is True:
32 dims = [latent_size + 2*fourier_degree*3] + dims + [1]
33 else:
34 dims = [latent_size + 3] + dims + [1]
35
36 self.positional_encoding = positional_encoding
37 self.fourier_degree = fourier_degree
38 self.num_layers = len(dims)
39 self.norm_layers = norm_layers
40 self.latent_in = latent_in
41 self.latent_dropout = latent_dropout
42 if self.latent_dropout:
43 self.lat_dp = nn.Dropout(0.2)
44
45 self.xyz_in_all = xyz_in_all
46 self.weight_norm = weight_norm
47
48 for layer in range(0, self.num_layers - 1):
49 if layer + 1 in latent_in:
50 out_dim = dims[layer + 1] - dims[0]
51 else:
52 out_dim = dims[layer + 1]
53 if self.xyz_in_all and layer != self.num_layers - 2:
54 out_dim -= 3
55
56 if weight_norm and layer in self.norm_layers:
57 setattr(
58 self,
59 "lin" + str(layer),
60 nn.utils.weight_norm(nn.Linear(dims[layer], out_dim)),
61 )
62 else:
63 setattr(self, "lin" + str(layer), nn.Linear(dims[layer], out_dim))
64
65 if (
66 (not weight_norm)
67 and self.norm_layers is not None
68 and layer in self.norm_layers

Callers 2

demo_optimizer.pyFile · 0.85
main_functionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected