WIP Indexing autograd and tests, new loss functions#47
Open
syurkevi wants to merge 5 commits intoarrayfire:masterfrom
Open
WIP Indexing autograd and tests, new loss functions#47syurkevi wants to merge 5 commits intoarrayfire:masterfrom
syurkevi wants to merge 5 commits intoarrayfire:masterfrom
Conversation
pavanky
requested changes
Oct 1, 2018
include/af/autograd/Functions.hpp
Outdated
|
|
||
| Variable operator !(const Variable &input); | ||
| Variable select_index(const Variable &input, const Variable &idx); | ||
| Variable set_index(const Variable &input, const Variable &idx, const Variable &vals); |
Member
There was a problem hiding this comment.
I think lookup and assign are better. Or go withgather vs scatter like tensorflow.
src/autograd/Functions.cpp
Outdated
|
|
||
| auto grad_func = [](std::vector<Variable> &inputs, const Variable &grad_output) { | ||
| auto grad = inputs[2].array(); | ||
| auto grad_mask = af::where(grad); |
Member
There was a problem hiding this comment.
Why are you converting idx into a mask and converting it back into an index again? This is making unnecessary copies.
src/autograd/Functions.cpp
Outdated
|
|
||
| inputs[0].addGrad(Variable(grad, false)); | ||
| }; | ||
| return Variable(result, {input, idx, Variable(mask, false)}, grad_func); |
Member
There was a problem hiding this comment.
You only need idx or mask. Not both.
src/autograd/Functions.cpp
Outdated
| auto grad_func = [](std::vector<Variable> &inputs, const Variable &grad_output) { | ||
| inputs[0].addGrad(inputs[3] * grad_output); | ||
| }; | ||
| return Variable(result, {input, idx, vals, Variable(mask, false)}, grad_func); |
Member
There was a problem hiding this comment.
It is better to use just index and do the masking inside the grad_func. No reason to do the masking op until it is necessary.
9prady9
reviewed
Oct 2, 2018
| if(PACKAGE_TESTS) | ||
| enable_testing() | ||
| add_subdirectory(tests) | ||
| endif() |
Member
There was a problem hiding this comment.
You can avoid creating a separate option PACKAGE_TESTS. gtest automatically addes BUILD_TESTING which you can use.
This file contains hidden or 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
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.
Adds new indexing functions to address #43. Theses are needed to implement Losses ans SVM from #34 and #6 those changes are next in line.
Operator overloading currently avoided in favor of new select_index () and set_index functions(). Will change to preferred solution as part of review.
Also brings in google test framework for testing. examples/autograd.cpp has been converted to (non-comprehensive) tests.