MCPcopy Create free account
hub / github.com/Zhiyuan-R/Tiger-Diffusion / create_mlp_components

Function create_mlp_components

model/tiger.py:14–44  ·  view source on GitHub ↗
(in_channels, out_channels, classifier=False, dim=2, width_multiplier=1)

Source from the content-addressed store, hash-verified

12
13
14def create_mlp_components(in_channels, out_channels, classifier=False, dim=2, width_multiplier=1):
15 r = width_multiplier
16
17 if dim == 1:
18 block = _linear_gn_relu
19 else:
20 block = SharedMLP
21 if not isinstance(out_channels, (list, tuple)):
22 out_channels = [out_channels]
23 if len(out_channels) == 0 or (len(out_channels) == 1 and out_channels[0] is None):
24 return nn.Sequential(), in_channels, in_channels
25
26 layers = []
27 for oc in out_channels[:-1]:
28 if oc < 1:
29 layers.append(nn.Dropout(oc))
30 else:
31 oc = int(r * oc)
32 layers.append(block(in_channels, oc))
33 in_channels = oc
34 if dim == 1:
35 if classifier:
36 layers.append(nn.Linear(in_channels, out_channels[-1]))
37 else:
38 layers.append(_linear_gn_relu(in_channels, int(r * out_channels[-1])))
39 else:
40 if classifier:
41 layers.append(nn.Conv1d(in_channels, out_channels[-1], 1))
42 else:
43 layers.append(SharedMLP(in_channels, int(r * out_channels[-1])))
44 return layers, out_channels[-1] if classifier else int(r * out_channels[-1])
45
46
47def create_pointnet_components(blocks, in_channels, embed_dim, with_se=False, normalize=True, eps=0,

Callers 1

__init__Method · 0.70

Calls 2

SharedMLPClass · 0.90
_linear_gn_reluFunction · 0.70

Tested by

no test coverage detected