Problem with "manual" Convolution() in Brainscript / misleading documentation
Hi,
I encountered a seemingly simple problem when trying to do a "manual" Convolution() in Brainscript (as in the old days before ConvolutionalLayer{}). I need to do it manually because I do not want to use the automatically generated kernel but a custom kernel (partly trainable, partly constant). The shape of the kernel is the same as any regular convolution kernel.
In the following, assume I want to convolve a padded [96x96x15] input with a [41x41x15x15] kernel (i.e., 41x41 kernel "field of view", 15 inputs, 15 outputs)
According to the documentation the syntax is supposed to be the following:
Convolution(w, input, {kernel dimensions}, mapDims = {map dimensions}, .... more options)
According to the documentation, w (the kernel) is supposed to have dimension [outChannels, (M1*M2...*Mn)]. If I do exactly that (debugged in the code to make sure I did it 100% correctly), i.e., dimension of w is [15x25215], I get the error message:
"Convolution weight matrix w should have dimension [(filter shape) x (input channels) x (output channels)]"
which contradicts with the documentation. Indeed, the former error message which matches the documentation is commented out in the code, so this was probably changed?
Given the error, I tried it the other way and even some more ways, neither of them worked, all producing the same error (which unfortunately does not hint at what is going wrong).
The shapes I tried:
[15x25215] # documentation [41x41x15x15] [1681x15x15] [25215x15]
and the {kernel dimensions} I tried:
(41:41:15) # documentation (41:41)
and the {mapdims = } I tried:
15 0 # this actually resulted in a different error, but did not work either
... and (almost) all cartesian products thereof and probably even some more.
TL;DR:
What is the correct way to use the Convolution command/macro in Brainscript? The documentation seems to be outdated and the error message is not very helpful either.
Any help highly appreciated!
Best, Daniel
P.S.: version is latest master
It seems like I found the problem in my implementation, I mixed up the kernel dimension parameters. However ...
- the documentation is still outdated.
- the error message is still misleading (it indicates a problem with the shape rather than dimension parameter).
- the commented-out code is still there.
I will thus leave this issue open for now. I will probably have time next week to create a pull request fixing this.
Update: I had more urging matters to handle, lately, but I did not forget and will come back to this.
We will be happy to receive a PR. We have been updating the Python-side documentation (where all shapes are reversed), but not so much the BS documentation. When in doubt, it's good to check the Python docs as well.
I'm going to close this since it's been a while. Feel free to reopen if there are updates.