Hello,
I’d like to understand where is my mistake on training and predicting from a model.
My goal is to predict a value to be either odd or even, (or out of vocabulary), so a kind of classification.
But after training is fully completed I test my model using unseen values and the prediction output gave me unexpected and always the same result.
Note this is only for testing and the final accuracy does not matter to me.
Here is what I did using nodejs tensorflow Api :
- I rougthly have 10000 values on dataset, half of data is labeled as “odd” and the other half is “even” ; do you think it is enough ? how many input should I train for such use case ?
- Values are positive float values
- min value 0.0016584342301295685
- max value 9.998886873517526
- On my data I took parseInt(floatValue) so that I consider only the integer value for the label Odd/Even => e.g.: 1.2 is Odd as well as 1.9
- I set 90% training and 10% validating from that dataset ; and I pick training data randomly (after shuffleling).
- I set 50 epochs and 20 batch size… just pick those values for testing.
- Training gave me : 0.7347 as loss and 0.4969 as accuracy… So I’m expecting to have 50% errors on predictions … very bad, but again, I don’t care because I’m just testing my development.
- But when I’m requesting my code to predict from unseen values I got the following results :
- 1.2 ==> Odd with a score of 0.481
- 1.5 ==> Odd with a score of 0.481
- 1.9 ==> Odd with a score of 0.481
FYI: The model is the following :
const model = tf.sequential();
model.add(tf.layers.dense({
inputShape: [ 1 ],
units: 1,
activation: "relu"
}));
model.add(tf.layers.dense({
units: 3, // because I consider 3 possible values "odd", "even" or "oov" for 'out of vocabulary' either it does not make a lot of sense in this context
activation: "softmax"
}));
What do you think ? where could be my mistakes ?
Thanks.