kronenthaler / libai

4 stars 2 forks source link

NeuralNetwork not completely honoring the offset value #32

Closed dktcoding closed 7 years ago

dktcoding commented 7 years ago

This is actually a minor issue, but when calling NeuralNetwork#error() or MLP#train() with an offset, values outside the range [offset, offset + length] should be completely ignored, thus they could very well be null. Currently the code accesses element [0] of the array instead of element at position [offset].

Other NN seem to be unaffected since they handle the offset value differently.

kronenthaler commented 7 years ago

Accessing element [0] is just for initialization purposes. As all answer vectors should have the same dimensions and it's assume there is at least 1 answer pattern, it doesn't matter really if its the 0, 1 or X. On the other hand, maybe there are not enough answers to access the offset (input validation should enter here to avoid this, though). Accessing the element 0 it's the safest simpler option. About the offset+length, input validation should cover this case as well.

dktcoding commented 7 years ago

Yeahp, I'll cancel the PR and start working on input validation.