-
Notifications
You must be signed in to change notification settings - Fork 18.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Crop layer for automatically aligning computations #1639
Closed
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
longjon
added a commit
to longjon/caffe
that referenced
this pull request
Dec 29, 2014
Crop layer for automatically aligning computations
longjon
added a commit
to longjon/caffe
that referenced
this pull request
Dec 29, 2014
Crop layer for automatically aligning computations
45af8f3
to
c1b7bab
Compare
Updated: now using a CUDA kernel for the GPU implementation, with much more reasonable performance. |
longjon
added a commit
to longjon/caffe
that referenced
this pull request
Dec 29, 2014
Crop layer for automatically aligning computations
longjon
added a commit
to longjon/caffe
that referenced
this pull request
Dec 29, 2014
Crop layer for automatically aligning computations
longjon
added a commit
to longjon/caffe
that referenced
this pull request
Dec 30, 2014
Crop layer for automatically aligning computations
longjon
added a commit
to longjon/caffe
that referenced
this pull request
Dec 30, 2014
Crop layer for automatically aligning computations
longjon
added a commit
to longjon/caffe
that referenced
this pull request
Dec 30, 2014
Crop layer for automatically aligning computations
longjon
added a commit
to longjon/caffe
that referenced
this pull request
Dec 30, 2014
Crop layer for automatically aligning computations
longjon
added a commit
to longjon/caffe
that referenced
this pull request
Dec 31, 2014
Crop layer for automatically aligning computations
longjon
added a commit
to longjon/caffe
that referenced
this pull request
Dec 31, 2014
Crop layer for automatically aligning computations
longjon
added a commit
to longjon/caffe
that referenced
this pull request
Dec 31, 2014
Crop layer for automatically aligning computations
longjon
added a commit
to longjon/caffe
that referenced
this pull request
Jan 1, 2015
Crop layer for automatically aligning computations
longjon
added a commit
to longjon/caffe
that referenced
this pull request
Jan 2, 2015
Crop layer for automatically aligning computations
longjon
added a commit
to longjon/caffe
that referenced
this pull request
Jan 2, 2015
Crop layer for automatically aligning computations
longjon
added a commit
to longjon/caffe
that referenced
this pull request
Jan 3, 2015
Crop layer for automatically aligning computations
longjon
added a commit
to longjon/caffe
that referenced
this pull request
Jan 3, 2015
Crop layer for automatically aligning computations
This will be useful for keeping track of the coordinate transformations induced by, e.g., convolution and pooling layers.
This allows layers to do things that depend, e.g., on net topology.
philkr
added a commit
to philkr/caffe
that referenced
this pull request
Jan 25, 2015
Crop layer for automatically aligning computations
This was referenced Feb 20, 2015
Closed
Replaced by #1976. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
After #1637 and #1638 (new content is just the commit longjon@4e38c93).
Existing layers shift and warp coordinate space: translation by padding (or lack thereof), contraction by strided convolution or pooling, and expansion by strided deconvolution (#1615). Often one wants to align two blobs, e.g., to establish a correspondence between input and output, or to fuse two different paths of computation. Counting conv/deconv strides to ensure that blob coordinates have the same scale is generally straightforward. Computing the offset between two blobs that results from intermediate padding and kernel sizes is trickier.
This layer takes two bottom blobs and produces one top, which is a copy of the first bottom cropped to the size of the second so that coordinates exactly correspond, i.e., it makes sense to fuse or compare the top blob with the second bottom, regardless of whatever padding or other shenanigans took place between their computation.
This is done by computing the coordinate mapping between the two bottom blobs, as provided by #1637 and made accessible by #1638. If that mapping is a simple translation, and has the right sign to allow the first blob to be "cropped to" the second, the layer simply performs the copy. If the mapping is not an integer translation, or the translation has the wrong sign, an error is thrown, and the net may be rearranged to allow sensible fusion.
The implementation of
LayerSetUp
amounts to some simple graph traversal to find the path connecting the two bottoms. CurrentlyNet
does not provide great facilities for traversing the layer graph, so it's a bit cumbersome; maybe this can be improved in the future.There is a bit of engineering involved in these three PRs, but the result is pretty convenient: what was before a tricky offline calculation becomes a trivial layer specification.
Another way to implement this, without #1638, would be to remove the graph traversal from
CropLayer
, giving it a simple parameter instead, and provide some other mechanism for automatically filling in that parameter.Currently CPU and GPU (trivially) are provided, but tests and documentation are not.