Closed dktcoding closed 7 years ago
I think the simplest most uniform would be throwing an IllegalArgumentException with a very descriptive message. What i want to avoid is having a heavy validation on each operation, keeping it simple as a dimension matching check should be enough.
Regarding the neural networks, the validation of the pattern/answer dimension should be limited to column vectors, patterns and answers should be able to have different dimensions and the neural network should create the inner matrices with the proper dimensions.
That was my idea, I think that with good input validation in the constructors, and some very specific methods (for instance in the case of MLP
also setTrainingType(int, double...)
) should suffice.
I think I "miss wrote" on the pattern/answer dimension, I was referring to length of the arrays (the pattern input array needs to be the same length than the answers array), different dimensions (eg. 10 input neurons 5 output neurons) are actually working well.
ah, true, they should match lengths.
Progress:
libai.common
Matrix
libai.common.nn
NeuralNetwork
libai.common.nn.supervised
Adaline
LVQ
MLP
Perceptron
RVF
SVM
libai.common.nn.unsupervised
Competitive
Hebb
Hopfield
Kohonen
All classes have been changed to incorporate validations. Some validations are now enforced statically by a type constrain (Column type instead of checking Matrix dimensions). What is not enforced by types it's checked on the train methods or constructors.
Hi there,
I was trying to complete the
JavaDoc
and input validation of theMatrix
class, and hit a minor issue that actually needs discussion for all the classes, since there are a LOT of ways of actually implementing input validation and it would be nice to to it consistently acrosslibai
.The idea I have right now it to validate all "big" (
public
) methods withException
s, like constructors, add, multiply, etc, and use assertions for performance critical methods likeposition(int, int)
andposition(int, int, double)
where actually anArrayIndexOutOfBoundsException
is implied and will be risen if anything goes wrong.Finally apply the same for things like
MLP
where (for instance) right now no validation is done about the length ofpatterns
andanswers
and actually leads to some very obscure errors.For private methods, we could add input validation for debugging, but it seems like an overkill since we can "be sure" about the inputs the methods are receiving...
What do you think?
PS: I couldn't add notes to the project... PPS: I'm momentarily back to work, so I might be a bit inactive for the next couple weeks.