提交 692204ee 编写于 作者: Y Yang Nie 提交者: Tingquan Gao

fix code style

上级 e7ad3909
...@@ -58,8 +58,8 @@ class InvertedResidual(nn.Layer): ...@@ -58,8 +58,8 @@ class InvertedResidual(nn.Layer):
expand_ratio: Union[int, float], expand_ratio: Union[int, float],
dilation: int=1, dilation: int=1,
skip_connection: Optional[bool]=True) -> None: skip_connection: Optional[bool]=True) -> None:
super().__init__()
assert stride in [1, 2] assert stride in [1, 2]
super(InvertedResidual, self).__init__()
self.stride = stride self.stride = stride
hidden_dim = make_divisible(int(round(in_channels * expand_ratio)), 8) hidden_dim = make_divisible(int(round(in_channels * expand_ratio)), 8)
...@@ -101,7 +101,7 @@ class InvertedResidual(nn.Layer): ...@@ -101,7 +101,7 @@ class InvertedResidual(nn.Layer):
self.exp = expand_ratio self.exp = expand_ratio
self.dilation = dilation self.dilation = dilation
def forward(self, x, *args, **kwargs): def forward(self, x):
if self.use_res_connect: if self.use_res_connect:
return x + self.block(x) return x + self.block(x)
else: else:
...@@ -197,8 +197,8 @@ class MobileViTV2Block(nn.Layer): ...@@ -197,8 +197,8 @@ class MobileViTV2Block(nn.Layer):
conv_ksize: Optional[int]=3, conv_ksize: Optional[int]=3,
dilation: Optional[int]=1, dilation: Optional[int]=1,
attn_norm_layer: Optional[str]=layer_norm_2d): attn_norm_layer: Optional[str]=layer_norm_2d):
super().__init__()
cnn_out_dim = attn_unit_dim cnn_out_dim = attn_unit_dim
padding = (conv_ksize - 1) // 2 * dilation padding = (conv_ksize - 1) // 2 * dilation
conv_3x3_in = nn.Sequential( conv_3x3_in = nn.Sequential(
('conv', nn.Conv2D( ('conv', nn.Conv2D(
...@@ -213,7 +213,6 @@ class MobileViTV2Block(nn.Layer): ...@@ -213,7 +213,6 @@ class MobileViTV2Block(nn.Layer):
conv_1x1_in = nn.Sequential(('conv', nn.Conv2D( conv_1x1_in = nn.Sequential(('conv', nn.Conv2D(
in_channels, cnn_out_dim, 1, bias_attr=False))) in_channels, cnn_out_dim, 1, bias_attr=False)))
super().__init__()
self.local_rep = nn.Sequential(conv_3x3_in, conv_1x1_in) self.local_rep = nn.Sequential(conv_3x3_in, conv_1x1_in)
self.global_rep, attn_unit_dim = self._build_attn_layer( self.global_rep, attn_unit_dim = self._build_attn_layer(
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册