0
$\begingroup$

I am learning tensorflow js, and I try some new things to me:

The situation: I generate false data of this type:

inputs:
[[12], [18], [12], [12], [18], [12], [12], [12]] 
...
[[12], [12], [18], [12], [12], [12], [18], [12]] 

labels one hot encoded:
[[1, 0], [0, 1] ...]

[1, 0] = "normal" (12)
[0, 1] = "error" (18)

then I have this model:

const model = tf.sequential();
model.add(tf.layers.dense({  inputShape: [1], units: 30, activation: "relu" }));
model.add(tf.layers.dense({  units: 2, activation: "softmax" })); // softmax and sigmoid works

after training, I test some data:

example: 
[[12], [18]] 
it work well: 
[[0.98, 0.003], [0.003, 0.98]]

My problem: I want to go deeper, I want to predict the correct label on these type of data:

inputs:
[[12], [18], [12], [12], [12], [6], [8], [7]] 
...
[[12], [12], [18], [12], [18], [12], [6], [7]] 

labels one hot encoded:
[1, 0, 0] = "normal" (12)
[0, 1, 0] = "error1" (18)
[0, 0, 1] = "error2" (6)

8-7 is a "normal corrupted data": after an error2 there is some factor on normal data

I want to find the right label for all data and I want to use LSTM for that, but how can I present my data so they have a "sequence" format ? is the size of the time is arbitrary ?

I tried things like:

const model = tf.sequential();
model.add(tf.layers.inputLayer({  inputShape: [3, 1] })); // inputShape: [5, 1], [1, 1]...
model.add(tf.layers.lstm({ units: 12 })); 
model.add(tf.layers.dense({  units: 3, activation: "softmax" })); 

But it returned bad accuracy (0.8) and I can't classify anything with it, if someone can explain to me how I have to chose my input shape for this type of model ?

thank you

$\endgroup$

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.