-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
templating return type of loss functions #2339
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
Conversation
|
Hi, Can anyone tell what has happened to Linux builds? |
zoq
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some really minor style issues, if you can fix those, this is ready from my side.
src/mlpack/methods/ann/loss_functions/sigmoid_cross_entropy_error.hpp
Outdated
Show resolved
Hide resolved
src/mlpack/methods/ann/loss_functions/negative_log_likelihood.hpp
Outdated
Show resolved
Hide resolved
src/mlpack/methods/ann/loss_functions/mean_squared_logarithmic_error.hpp
Outdated
Show resolved
Hide resolved
d8b37e2 to
b196896
Compare
favre49
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, could you also add to HISTORY.md?
|
Hey @mrityunjay-tripathi, @favre49, @zoq Do you think there should be a way to test this ? |
Sure @kartikdutt18. Testing for the precision of all the loss functions is going to be a lot of work. But the currently added test of loss functions doesn't have even precision sufficient for |
|
I don't think we need to add tests for all layers. A single test to show that various data types like float can be used as both input and output. Let me know what you think. |
|
Hey @mrityunjay-tripathi, I looked around and I found this issue #506, So this what I think you can do. In loss function tests use arma::fmat in some cases (not all so that we preserve double as well). We need not check for precision or datatype of output. If this works correctly, which I think it does it will return the correct output. The way we will test is by using something similar to |
|
It's good that builds are passing :) |
|
Personally, I'm not a fan of the idea of testing float on some tests and double on others - it makes the tests more convoluted and confusing, and doesn't feel like good testing practice. To me, the point of these tests is ensuring the loss functions return the correct "answer". I agree with @mrityunjay-tripathi that the datatype of these tests feels like something that we should be trusting Armadillo on.
I'm not sure I understood this? Ideally the fact that this works should be obvious from documentation, not from tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Second approval provided automatically after 24 hours. 👍
Generally I feel many people learn about the codebase by looking at the tests and why certain things are implemented they way are. Since what we had worked and we are adding another feature it made sense to me test the problem that it aimed to solve (in this case, using float datatype) before we merged it. Create a separate Test Case, say Maybe it's a problem with me, I consider testing to be absolutely necessary for any feature addition, but maybe it's unnecessary here. If you will feel that it is unnecessary, @mrityunjay-tripathi can use |
|
That's okay. No test is unnecessary. Let's wait and see what other members think. |
|
I like the general idea, in ensmallen, we run each test against So ideally we can do the same here in mlpack, that includes everything, not only the ann methods. That said, I think it's out of scope for this particular PR. Also, we have to make sure the datatype used makes sense, like using |
|
So personally I would revert the change, the changes work with our main datatype right now, so it doesn't break anything. |
This looks nice. It should not be hard to extend tests for fmat as well, I think we would be able to close #1062 when methods (other than ann) also support float and are tested. Do you mind if I open up an issue for new contributors to get involved with the codebase through testing or I can create a PR as well if this seems like something that we can add.
Agreed, that makes sense. |
|
Till then @mrityunjay-tripathi, Kindly revert the changes and we can merge this. Hopefully tests for fmat etc. will follow soon. Sorry that you and @favre49, had to deal with me. Thanks a lot. |
9adf0e3 to
2f23fe8
Compare
zoq
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution, no more comments from my side.
|
Thanks again, that is a good basis we can build on. |
In accordance to #2338
Any other suggestions/ideas are most welcome.