-
Notifications
You must be signed in to change notification settings - Fork 0
/
P2_300_10.py
40 lines (28 loc) · 1.22 KB
/
P2_300_10.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
from lib.model.conv_branch import ConvBranch
from lib.model.pool_branch import PoolBranch
from .gaussian import GaussianNoise
n_branches = 306
def set_func(layer, in_planes, out_planes):
layer.branch_0 = ConvBranch(in_planes, out_planes, kernel_size=3, padding=1)
layer.branch_1 = ConvBranch(in_planes,
out_planes,
kernel_size=3,
padding=1,
separable=True)
layer.branch_2 = ConvBranch(in_planes, out_planes, kernel_size=5, padding=2)
layer.branch_3 = ConvBranch(in_planes,
out_planes,
kernel_size=5,
padding=2,
separable=True)
layer.branch_4 = PoolBranch(in_planes, out_planes, 'avg')
layer.branch_5 = PoolBranch(in_planes, out_planes, 'max')
layer.branch_6 = GaussianNoise(10.)
return n_branches
def pick_func(layer, layer_type, x):
if layer_type < 6:
out = getattr(layer, "branch_{}".format(layer_type.cpu().item()))(x)
elif 6 <= layer_type < 306:
out = layer.branch_6(x)
return out
functions = (set_func, pick_func)