Skip to content
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

Fixed label mask index in computeGradientAndScore #5595

merged 1 commit into from Jun 15, 2018


Copy link

commented Jun 14, 2018

I am using a ComputationGraph configuration with two outputs and a MultiDataSetIterator with two outputs and two output masks. During training, computeGradientAndScore() fails because the mask is accessed with a wrong index (2 instead of 1).

14.06.18 11:50:30 [main] WARN  o.d.e.t.BaseEarlyStoppingTrainer:118 Early stopping training terminated due to exception at epoch 0, iteration 0
java.lang.ArrayIndexOutOfBoundsException: 2
	at org.deeplearning4j.nn.graph.ComputationGraph.computeGradientAndScore( ~[deeplearning4j-nn-1.0.0-beta.jar:na]
	at org.deeplearning4j.nn.graph.ComputationGraph.computeGradientAndScore( ~[deeplearning4j-nn-1.0.0-beta.jar:na]
	at org.deeplearning4j.optimize.solvers.BaseOptimizer.gradientAndScore( ~[deeplearning4j-nn-1.0.0-beta.jar:na]
	at org.deeplearning4j.optimize.solvers.StochasticGradientDescent.optimize( ~[deeplearning4j-nn-1.0.0-beta.jar:na]
	at org.deeplearning4j.optimize.Solver.optimize( ~[deeplearning4j-nn-1.0.0-beta.jar:na]
	at ~[deeplearning4j-nn-1.0.0-beta.jar:na]
	at ~[deeplearning4j-nn-1.0.0-beta.jar:na]
	at ~[deeplearning4j-nn-1.0.0-beta.jar:na]
	at ~[deeplearning4j-nn-1.0.0-beta.jar:na]

In computeGradientAndScore(), outNum is incremented twice in the case of multiple output masks (line 1399 and 1408). This is an easy fix that corrects this error with no side effects, because outNum is solely used to access output masks.

Copy link

left a comment

LGTM, thanks!

@AlexDBlack AlexDBlack merged commit 4344e00 into eclipse:master Jun 15, 2018

1 of 2 checks passed

continuous-integration/jenkins/pr-merge The build of this commit was aborted
codeclimate All good!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.