CS-7641-assignments icon indicating copy to clipboard operation
CS-7641-assignments copied to clipboard

Assignment 2 : Neural network bits fail with java.lang.IndexOutOfBoundsException

Open timuster opened this issue 7 years ago • 5 comments

Running the following files with Jython throws an Index out of bounds error (when using CreditApprovalData or PenDigitsData).

  • NN-Backprop.py
  • NN-GA.py
  • NN-RHC.py
  • NN-SA.py

$ jython NN-Backprop.py

Using seed 653091685

Error results for Backprop

Traceback (most recent call last): File "NN-Backprop.py", line 48, in main() File "NN-Backprop.py", line 38, in main train(BatchBackPropagationTrainer(data_set, classification_network, measure, rule), classification_network, File "/CS-7641-assignments/assignment2/base.py", line 132, in train oa.train() at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64) at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70) at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:248) at java.base/java.util.Objects.checkIndex(Objects.java:372) at java.base/java.util.ArrayList.get(ArrayList.java:440) at func.nn.Layer.getNode(Layer.java:43) at func.nn.Layer.setActivations(Layer.java:60) at func.nn.LayeredNetwork.setInputValues(LayeredNetwork.java:53) at func.nn.backprop.BatchBackPropagationTrainer.train(BatchBackPropagationTrainer.java:46) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:564)

java.lang.IndexOutOfBoundsException: java.lang.IndexOutOfBoundsException: Index 8 out-of-bounds for length 8 `

timuster avatar Feb 17 '19 22:02 timuster

  • I tested this on both MacOS and Ubuntu (Jython was installed using the official jar and not homebrew / apt)
  • I did run python run_experiment.py --dump_data and the 3 'toy-problems' before trying to run the 4 NN scripts mentioned above.
  • I don't see this error when using the "HTRU2" data, but the CreditApprovalData & PenDigitsData throw the error (configured by changing 'DS_NAME' in base.py)...

timuster avatar Feb 17 '19 22:02 timuster

I figured that this can be resolved by properly setting the input layer size in the specific files... I'll let this issue stay 'open' in case you'd like help updating the README (post a comment and I can create a pull-request).

Thanks for the project, Chad!

timuster avatar Feb 18 '19 00:02 timuster

If I'm following correctly you're saying the INPUT_LAYER and OUTPUT_LAYER settings have to be changed for the data sets and that's not clear in the readme? If so feel free to open a PR. An alternative might be to update base.py in order specify these settings in one place, similar to how DS_NAME is set there. In fact all those layer settings should probably be in base.py...

cmaron avatar Feb 27 '19 19:02 cmaron

agree, ran into this exact issue. thanks for filling the issue @timuster. happy to help move up those settings once i finish catching up on this dang assignment...

swyxio avatar Mar 03 '19 01:03 swyxio

@timuster and @sw-yx I've updated the readme, let me know if you have more to add.

cmaron avatar Mar 07 '19 00:03 cmaron