Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a great implementation! One small note:
On line 151:
I believe you should set the
arange
to be from1 -> N
, rather than from0 -> (N-1)
:Doing this will ensure that the filter locations are around the center,
gx
andgy
. Here's a figure from the paper for reference:Currently the grid is shifted more towards the top-left by 1 filter.
Below are some diagrams showing the differences between the current grid and the correct grid:
The red dot is the center
gx
andgy
. The green rectangle is the current grid layout/filter locations, and the red rectangle is the correct grid layout/filter locations, using the recommended code change mentioned above.Example 1 (N=5):
Notice how the filter grid contains
gx
andgy
, but isn't centered around it!Example 2 (N=2):
Notice how the filter locations don't even contain
gx
andgy
! One of DRAW's optimal configurations for MNIST was using aread_N
of 2Details about the above figure:
Image size: 25 x 25
gx = 10
gy = 12
N = 5 (for the first example)
N = 2 (for the second example)
(delta) stride = 3
To calculate the NxN filter locations: We can use Equations 19 and 20 from the paper.
In your code it's:
To draw the rectangle, we need the top-left and bottom-right filter locations.
We can simple set the starting and ending grid_i values as so:
With the current
arange
, we would setgrid_i = 0
andgrid_i = N-1
With the proposed
arange
, we would setgrid_i = 1
andgrid_i = N