-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinception_b.py
23 lines (18 loc) · 868 Bytes
/
inception_b.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import torch
from torch import nn
from torch.nn import functional as F
from torch_modules.conv2d_bn_relu import Conv2dBNRelu
class InceptionB(nn.Module):
def __init__(self, in_channels: int):
super().__init__()
self.branch3x3 = Conv2dBNRelu(in_channels, 384, kernel_size=3, stride=2)
self._branch3x3_1 = Conv2dBNRelu(in_channels, 64, kernel_size=1)
self._branch3x3_2 = Conv2dBNRelu(64, 96, kernel_size=3, padding=1)
self._branch3x3_3 = Conv2dBNRelu(96, 96, kernel_size=3, stride=2)
def forward(self, x):
branch3x3 = self.branch3x3(x)
_branch3x3 = self._branch3x3_1(x)
_branch3x3 = self._branch3x3_2(_branch3x3)
_branch3x3 = self._branch3x3_3(_branch3x3)
branch_pool = F.max_pool2d(x, kernel_size=3, stride=2)
return torch.cat([branch3x3, _branch3x3, branch_pool], 1)