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
merged 1 commit into from Jun 15, 2018

Conversation

@sebastianarnold
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(ComputationGraph.java:1335) ~[deeplearning4j-nn-1.0.0-beta.jar:na]
	at org.deeplearning4j.nn.graph.ComputationGraph.computeGradientAndScore(ComputationGraph.java:1280) ~[deeplearning4j-nn-1.0.0-beta.jar:na]
	at org.deeplearning4j.optimize.solvers.BaseOptimizer.gradientAndScore(BaseOptimizer.java:178) ~[deeplearning4j-nn-1.0.0-beta.jar:na]
	at org.deeplearning4j.optimize.solvers.StochasticGradientDescent.optimize(StochasticGradientDescent.java:60) ~[deeplearning4j-nn-1.0.0-beta.jar:na]
	at org.deeplearning4j.optimize.Solver.optimize(Solver.java:54) ~[deeplearning4j-nn-1.0.0-beta.jar:na]
	at org.deeplearning4j.nn.graph.ComputationGraph.fit(ComputationGraph.java:1104) ~[deeplearning4j-nn-1.0.0-beta.jar:na]
	at org.deeplearning4j.nn.graph.ComputationGraph.fit(ComputationGraph.java:985) ~[deeplearning4j-nn-1.0.0-beta.jar:na]
	at org.deeplearning4j.earlystopping.trainer.EarlyStoppingGraphTrainer.fit(EarlyStoppingGraphTrainer.java:80) ~[deeplearning4j-nn-1.0.0-beta.jar:na]
	at org.deeplearning4j.earlystopping.trainer.BaseEarlyStoppingTrainer.fit(BaseEarlyStoppingTrainer.java:116) ~[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.

@AlexDBlack
Copy link
Contributor

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
Details
codeclimate All good!
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.