Is 3D convolution supported ?
I tried 3D convolution using
c = Convolution(w, inp, (kW:kH:KD:1), mapDims=outMap, stride=(hStride:vStride:dStride:1), sharing = true, autoPadding = true, lowerPad = 0, upperPad = 0, transpose=false, imageLayout='CHW', maxTempMemSizeInSamples = 0, tag='')
And I got the error below: EXCEPTION occurred: Convolution operation currently only supports 1D or 2D convolution on 3D tensors.
I am wondering if 3D convolution is supported by CNTK now?
I think that's a bug in CNTK. 3D convolution is not supported for the old image layout (HWC), but it is for the new layout (cudnn or CHW), so CNTK attempts to change the layout, which does not work for 4D tensors. You can fix it by changing line 377 in file ConvolutionalNodes.h from
SetDims(ImageDimensions(outputShape, ImageLayoutKind::CHW).AsTensorShape;
to
if (m_imageLayout != ImageLayoutKind::CHW)
{
SetDims(ImageDimensions(outputShape, ImageLayoutKind::CHW).AsTensorShape(m_imageLayout), HasMBLayout());
}
else
{
SetDims(outputShape, HasMBLayout());
}
So the change is only done when needed.
@e-thereal
I will try it now. Thank you so much !!!
Really appreciate!
We are looking into this, expect a fix in master soon, plus clarified documentation.
@e-thereal @frankseide
It worked!
Just one thing, using Convolution(), the parameter stride should be "stride=(hStride:vStride:dStride:inMap)". "stride = 1" doesn't work.
Yes, the last parameter must match the input dimension, otherwise it would not be able to reduce. This is not nice. That is a quirk that we are going to address as well.
It was necessary to distinguish from images that have no channel dimension, e.g. a B&W image that is just a [W x H] tensor. For 2D convolution, it is clear. But for N-dim convolution, the system would not know whether H is supposed to match the input dimension or not. We need a better way of denoting this.
Hi @e-thereal, @cha-zhang put this fix in master. Will be in upcoming 1.7 binary. Thanks!
Great. Thanks for letting me know.
2016-08-22 23:31 GMT+02:00 Frank Seide [email protected]:
Closed #726 https://github.com/Microsoft/CNTK/issues/726.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Microsoft/CNTK/issues/726#event-763665680, or mute the thread https://github.com/notifications/unsubscribe-auth/AMdybCOQyyWeIr2cEuUUZBtFBdAfltODks5qihVFgaJpZM4JYf0f .
Just one thing, using Convolution(), the parameter stride should be "stride=(hStride:vStride:dStride:inMap)". "stride = 1" doesn't work
If you use ConvolutionalLayer{} instead, you will not need to specify it. If you use this, please for now always specify init=..., don't leave it to default.