-
Notifications
You must be signed in to change notification settings - Fork 0
/
reduction_A.py
45 lines (42 loc) · 1.6 KB
/
reduction_A.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
43
44
45
import mindspore as ms
import mindspore.nn as nn
import mindspore.ops.operations as operator
# import mindspore.dataset.transforms.vision.c_transforms as CV
# import mindspore.dataset.transforms.c_transforms as C
# from mindspore.dataset.transforms.vision import Inter
from mindspore.common import dtype as mstype
from mindspore.train.callback import ModelCheckpoint, CheckpointConfig, LossMonitor
from mindspore.common.initializer import TruncatedNormal
class reduction_A(nn.Cell):
def __init__(self, in_channle, bias=False):
super().__init__()
self.pool = nn.SequentialCell([
nn.MaxPool2d(kernel_size=3, stride=2, pad_mode="valid"),
])
self.cov3x3 = nn.SequentialCell([
nn.Conv2d(in_channle, 384, 3, stride=2, has_bias=bias, pad_mode="valid"),
nn.BatchNorm2d(384),
nn.ReLU()
])
self.conv1x1_conv3x3_conv3x3 = nn.SequentialCell([
nn.Conv2d(in_channle, 192, 1, has_bias=bias),
nn.BatchNorm2d(192),
nn.ReLU(),
nn.Conv2d(192, 224, 3, has_bias=bias),
nn.BatchNorm2d(224),
nn.ReLU(),
nn.Conv2d(224, 256, 3, stride=2, has_bias=bias, pad_mode="valid"),
nn.BatchNorm2d(256),
nn.ReLU()
])
self.cat = operator.Concat(1)
def construct(self, x):
pool_out = self.pool(x)
cov3x3_out = self.cov3x3(x)
conv1x1_conv3x3_conv3x3 = self.conv1x1_conv3x3_conv3x3(x)
x = self.cat((
pool_out,
cov3x3_out,
conv1x1_conv3x3_conv3x3,
))
return x