You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've met a problem with SpatialDepthWiseConvolution
When I pass image, say 4x5 (height=4, width=5), this layer outputs image 5x4.
Proof code:
-- Make model:
local model = nn.SpatialDepthWiseConvolution(3, 1, 3, 3, 1, 1, 1, 1)
-- Generate input: batch = 2, nChannels = 3, height = 4, width = 5
local X = torch.randn(2, 3, 4, 5)
print('X:\n'..tostring(X))
-- Pass input through SpatialDepthWiseConvolution
local Yhat = model:forward(X)
print('Yhat:\n'..tostring(Yhat))
This script outputs:
X: ...
[torch.DoubleTensor of size 2x3x4x5]
Yhat: ...
[torch.DoubleTensor of size 2x3x5x4]
This breaks all the sequence of NN, and model does not work as intended!
Also, this contradicts to documentation, that says:
The most noticiable difference is the output dimension of SpatialConvolution is nOutputPlane x oheight x owidth, while for SpatialDepthWiseConvolution it is (nOutputPlane x nInputPlane) x oheight x owidth.
The text was updated successfully, but these errors were encountered:
Unfortunately, I have no time to dig into C-code of THNN implementation of SpatialDepthWiseConvolution.
There is a way to emulate this module using containers Concat and Parallel along with standard SpatialConvolution module:
local depth_wise_conv = nn.Concat(2)
for o = 1, nOutputPlane do
local out = nn.Parallel(2, 2)
for i = 1, nInputPlane do
local seq = nn.Sequential()
local conv = nn.SpatialConvolution(1, 1, kW, kH, dW, dH, pW, pH):noBias()
conv.weight:copy(weight[o][i])
seq:add( nn.Reshape(1, inputHeight, inputWidth) )
seq:add( conv )
out:add( seq )
end
depth_wise_conv:add( out )
end
But I've spend some time and created a module in pure lua that performs spatial depth wise convolution and (I hope) works as intended. You may find source code and unit tests here: SpatialDepthWiseConvolution in torch (lua)
I'll be waiting for someone to fix this problem, because low-level implementation should be faster!
I've met a problem with SpatialDepthWiseConvolution
When I pass image, say 4x5 (height=4, width=5), this layer outputs image 5x4.
Proof code:
This script outputs:
This breaks all the sequence of NN, and model does not work as intended!
Also, this contradicts to documentation, that says:
The text was updated successfully, but these errors were encountered: