DepthwiseConv corrected again.
This commit is contained in:
parent
00a4f4c26d
commit
e9797408ec
@ -138,14 +138,11 @@ end
|
|||||||
"""
|
"""
|
||||||
DepthwiseConv(size, in=>out)
|
DepthwiseConv(size, in=>out)
|
||||||
DepthwiseConv(size, in=>out, relu)
|
DepthwiseConv(size, in=>out, relu)
|
||||||
|
|
||||||
Depthwise convolutional layer. `size` should be a tuple like `(2, 2)`.
|
Depthwise convolutional layer. `size` should be a tuple like `(2, 2)`.
|
||||||
`in` and `out` specify the number of input and output channels respectively.
|
`in` and `out` specify the number of input and output channels respectively.
|
||||||
Note that `out` must be an integer multiple of `in`.
|
Note that `out` must be an integer multiple of `in`.
|
||||||
|
|
||||||
Data should be stored in WHCN order. In other words, a 100×100 RGB image would
|
Data should be stored in WHCN order. In other words, a 100×100 RGB image would
|
||||||
be a `100×100×3` array, and a batch of 50 would be a `100×100×3×50` array.
|
be a `100×100×3` array, and a batch of 50 would be a `100×100×3×50` array.
|
||||||
|
|
||||||
Takes the keyword arguments `pad`, `stride` and `dilation`.
|
Takes the keyword arguments `pad`, `stride` and `dilation`.
|
||||||
"""
|
"""
|
||||||
struct DepthwiseConv{N,M,F,A,V}
|
struct DepthwiseConv{N,M,F,A,V}
|
||||||
@ -165,17 +162,18 @@ function DepthwiseConv(w::AbstractArray{T,N}, b::AbstractVector{T}, σ = identit
|
|||||||
return DepthwiseConv(σ, w, b, stride, pad, dilation)
|
return DepthwiseConv(σ, w, b, stride, pad, dilation)
|
||||||
end
|
end
|
||||||
|
|
||||||
DepthwiseConv(k::NTuple{N,Integer}, ch::Integer, σ = identity; init = glorot_uniform,
|
function DepthwiseConv(k::NTuple{N,Integer}, ch::Pair{<:Integer,<:Integer}, σ = identity;
|
||||||
stride = 1, pad = 0, dilation = 1) where N =
|
init = glorot_uniform, stride = 1, pad = 0, dilation = 1) where N
|
||||||
DepthwiseConv(init(k..., 1, ch), zeros(ch), σ,
|
@assert ch[2] % ch[1] == 0 "Output channels must be integer multiple of input channels"
|
||||||
stride = stride, pad = pad, dilation=dilation)
|
return DepthwiseConv(
|
||||||
|
init(k..., div(ch[2], ch[1]), ch[1]),
|
||||||
DepthwiseConv(k::NTuple{N,Integer}, ch::Pair{<:Integer,<:Integer}, σ = identity; init = glorot_uniform,
|
zeros(ch[2]),
|
||||||
stride::NTuple{N,Integer} = map(_->1,k),
|
σ;
|
||||||
pad::NTuple{N,Integer} = map(_->0,2 .* k),
|
stride = stride,
|
||||||
dilation::NTuple{N,Integer} = map(_->1,k)) where N =
|
pad = pad,
|
||||||
DepthwiseConv(init(k..., ch[2], ch[1]), zeros(ch[2]*ch[1]), σ,
|
dilation = dilation
|
||||||
stride = stride, pad = pad)
|
)
|
||||||
|
end
|
||||||
|
|
||||||
@treelike DepthwiseConv
|
@treelike DepthwiseConv
|
||||||
|
|
||||||
@ -196,7 +194,7 @@ end
|
|||||||
invoke(a, Tuple{AbstractArray}, x)
|
invoke(a, Tuple{AbstractArray}, x)
|
||||||
|
|
||||||
(a::DepthwiseConv{<:Any,<:Any,W})(x::AbstractArray{<:Real}) where {T <: Union{Float32,Float64}, W <: AbstractArray{T}} =
|
(a::DepthwiseConv{<:Any,<:Any,W})(x::AbstractArray{<:Real}) where {T <: Union{Float32,Float64}, W <: AbstractArray{T}} =
|
||||||
a(T.(x))
|
a(T.(x))
|
||||||
"""
|
"""
|
||||||
CrossCor(size, in=>out)
|
CrossCor(size, in=>out)
|
||||||
CrossCor(size, in=>out, relu)
|
CrossCor(size, in=>out, relu)
|
||||||
|
Loading…
Reference in New Issue
Block a user