-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Fix JacobianTest and CustomJacobianTest (Resolves #3470) #3471
Conversation
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.
I think this is correct. At least, it passes all the tests, but, all layers tested with the Jacobian test do not use the first argument to Backward()
. So what is needed is an audit: just need to look at all the layers, and see if they all use the convention that the first parameter to Backward()
is the output from Forward()
, not the input to Forward()
.
I'm not yet sure if this makes the Jacobian test succeed for the updated LogSoftMax
implementation.
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.
Went through and audited everything visually (quicker than I thought!).
- With this change the Jacobian test for the updated
LogSoftMax
layer passes. - Many layers simply ignore the first parameter to
Backward()
. - Several layers use the first parameter just to get the batch size (
.n_cols
). - A couple layers (
HardTanH
,LeakyReLU
,PReLU
) are such thatBaclward()
is correct regardless of whether the output from or input toFoward()
is passed. - I'm not 100% sure of
Softmax
but it looks like it takes the output. A test will tell us, I guess. - The same is true of
Softmin
, but just glancing at the backward expression, I think it might be wrong. We'll find out when we apply a test, I guess.
I would definitely like to get these tests applied to all layers. I was surprised to see when I went through the tests that only Linear3D
and LinearNoBias
are tested with the Jacobian test in the tests/ann/layer/
directory
It could be useful in a follow-up PR to either clearly document what the first parameter to Backward()
is, or change its name throughout the codebase, or both. I'm not sure what the best way forward there is.
Also to be noted, many activation functions incorrectly implement the I think I will make a list of all layers/functions which maybe have been incorrectly implemented, so that they can be fixed and additional tests(including the Jacobian test) be added along with the fix. |
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. 👍
Thanks again for finding this! |
Use output of the Forward method instead of input. Fixes #3470 (See issue for more details).