1
1
"""
2
2
conv_bn(kernelsize, inplanes, outplanes, activation = relu;
3
- rev = false, preact = false, use_bn = true,
4
- initβ = Flux.zeros32, initγ = Flux.ones32, ϵ = 1.0f-5, momentum = 1.0f-1 ,
5
- kwargs... )
3
+ rev = false, preact = false, use_bn = true, stride = 1, pad = 0, dilation = 1,
4
+ groups = 1, [bias, weight, init], initβ = Flux.zeros32, initγ = Flux.ones32 ,
5
+ ϵ = 1.0f-5, momentum = 1.0f-1 )
6
6
7
7
Create a convolution + batch normalization pair with activation.
8
8
55
55
56
56
"""
57
57
depthwise_sep_conv_bn(kernelsize, inplanes, outplanes, activation = relu;
58
- rev = false, use_bn1 = true, use_bn2 = true,
58
+ rev = false, use_bn = (true, true),
59
+ stride = 1, pad = 0, dilation = 1, [bias, weight, init],
59
60
initβ = Flux.zeros32, initγ = Flux.ones32,
60
- ϵ = 1.0f-5, momentum = 1.0f-1,
61
- stride = 1, kwargs...)
61
+ ϵ = 1.0f-5, momentum = 1.0f-1)
62
62
63
63
Create a depthwise separable convolution chain as used in MobileNetv1.
64
64
This is sequence of layers:
@@ -77,8 +77,7 @@ See Fig. 3 in [reference](https://arxiv.org/abs/1704.04861v1).
77
77
- `outplanes`: number of output feature maps
78
78
- `activation`: the activation function for the final layer
79
79
- `rev`: set to `true` to place the batch norm before the convolution
80
- - `use_bn1`: set to `true` to use a batch norm after the depthwise convolution
81
- - `use_bn2`: set to `true` to use a batch norm after the pointwise convolution
80
+ - `use_bn`: a tuple of two booleans to specify whether to use batch normalization for the first and second convolution
82
81
- `stride`: stride of the first convolution kernel
83
82
- `pad`: padding of the first convolution kernel
84
83
- `dilation`: dilation of the first convolution kernel
@@ -87,16 +86,16 @@ See Fig. 3 in [reference](https://arxiv.org/abs/1704.04861v1).
87
86
- `ϵ`, `momentum`: batch norm parameters (see [`Flux.BatchNorm`](#))
88
87
"""
89
88
function depthwise_sep_conv_bn (kernelsize, inplanes, outplanes, activation = relu;
90
- rev = false , use_bn1 = true , use_bn2 = true ,
89
+ rev = false , use_bn = ( true , true ) ,
91
90
initβ = Flux. zeros32, initγ = Flux. ones32,
92
91
ϵ = 1.0f-5 , momentum = 1.0f-1 ,
93
92
stride = 1 , kwargs... )
94
93
return vcat (conv_bn (kernelsize, inplanes, inplanes, activation;
95
94
rev = rev, initβ = initβ, initγ = initγ,
96
- ϵ = ϵ, momentum = momentum, use_bn = use_bn1 ,
95
+ ϵ = ϵ, momentum = momentum, use_bn = use_bn[ 1 ] ,
97
96
stride = stride, groups = Int (inplanes), kwargs... ),
98
97
conv_bn ((1 , 1 ), inplanes, outplanes, activation;
99
- rev = rev, initβ = initβ, initγ = initγ, use_bn = use_bn2 ,
98
+ rev = rev, initβ = initβ, initγ = initγ, use_bn = use_bn[ 2 ] ,
100
99
ϵ = ϵ, momentum = momentum))
101
100
end
102
101
0 commit comments