lin-shuyu / VAE-LSTM-for-anomaly-detection

We propose a VAE-LSTM model as an unsupervised learning approach for anomaly detection in time series.
468 stars 87 forks source link

Example doesn't seem to produce proper result for me #7

Open kb1ooo opened 4 years ago

kb1ooo commented 4 years ago

I ran the example in the README.md file and it doesn't look like it produced the correct results. All the reconstructions in the result directory for the experiment are just a constant mean signal (0). Here is what the output looks like from the training. Can you post what a proper result should look like for the example?

Finish processing the embeddings of the entire dataset.
The first a few embeddings are
[[-0.07727078 -0.0207611  -0.1191008   0.15289539  0.06768157  0.00136372]
 [ 0.00486088 -0.00883693  0.00458424  0.02584253  0.01832935 -0.02976965]
 [ 0.00974356  0.00351174 -0.01392651 -0.00980108 -0.00250123 -0.01614434]
 [-0.02508994  0.00390782 -0.07213792  0.06181057  0.02366055 -0.01901692]
 [ 0.00347477  0.00061497 -0.00568073  0.00633631  0.00377738 -0.00562688]]
Model: "model"
_________________________________________________________________
Layer (type)                 Output Shape              Param #   
=================================================================
input_1 (InputLayer)         [(None, 11, 6)]           0         
_________________________________________________________________
lstm (LSTM)                  (None, 11, 64)            18176     
_________________________________________________________________
lstm_1 (LSTM)                (None, 11, 64)            33024     
_________________________________________________________________
lstm_2 (LSTM)                (None, 11, 6)             1704      
=================================================================
Total params: 52,904
Trainable params: 52,904
Non-trainable params: 0
_________________________________________________________________
../experiments/local-results/NAB/machine_temp/batch-32/NAB-machine_temp-48-12-6-fixedSigma-0.1/checkpoint/lstm/checkpoint
No LSTM model loaded.
Train on 8932 samples, validate on 993 samples
Epoch 1/20
8864/8932 [============================>.] - ETA: 0s - loss: 0.0014 - mean_squared_error: 0.0014
Epoch 00001: saving model to ../experiments/local-results/NAB/machine_temp/batch-32/NAB-machine_temp-48-12-6-fixedSigma-0.1/checkpoint/lstm/cp.ckpt
8932/8932 [==============================] - 8s 842us/sample - loss: 0.0014 - mean_squared_error: 0.0014 - val_loss: 0.0013 - val_mean_squared_error: 0.0013
Epoch 2/20
8896/8932 [============================>.] - ETA: 0s - loss: 0.0012 - mean_squared_error: 0.0012
Epoch 00002: saving model to ../experiments/local-results/NAB/machine_temp/batch-32/NAB-machine_temp-48-12-6-fixedSigma-0.1/checkpoint/lstm/cp.ckpt
8932/8932 [==============================] - 6s 658us/sample - loss: 0.0012 - mean_squared_error: 0.0012 - val_loss: 0.0012 - val_mean_squared_error: 0.0012
Epoch 3/20
8864/8932 [============================>.] - ETA: 0s - loss: 0.0012 - mean_squared_error: 0.0012
Epoch 00003: saving model to ../experiments/local-results/NAB/machine_temp/batch-32/NAB-machine_temp-48-12-6-fixedSigma-0.1/checkpoint/lstm/cp.ckpt
8932/8932 [==============================] - 6s 662us/sample - loss: 0.0012 - mean_squared_error: 0.0012 - val_loss: 0.0011 - val_mean_squared_error: 0.0011
Epoch 4/20
8864/8932 [============================>.] - ETA: 0s - loss: 0.0011 - mean_squared_error: 0.0011
Epoch 00004: saving model to ../experiments/local-results/NAB/machine_temp/batch-32/NAB-machine_temp-48-12-6-fixedSigma-0.1/checkpoint/lstm/cp.ckpt
8932/8932 [==============================] - 6s 665us/sample - loss: 0.0011 - mean_squared_error: 0.0011 - val_loss: 0.0010 - val_mean_squared_error: 0.0010
Epoch 5/20
8864/8932 [============================>.] - ETA: 0s - loss: 0.0010 - mean_squared_error: 0.0010
Epoch 00005: saving model to ../experiments/local-results/NAB/machine_temp/batch-32/NAB-machine_temp-48-12-6-fixedSigma-0.1/checkpoint/lstm/cp.ckpt
8932/8932 [==============================] - 6s 661us/sample - loss: 0.0010 - mean_squared_error: 0.0010 - val_loss: 9.6235e-04 - val_mean_squared_error: 9.6235e-04
Epoch 6/20
8864/8932 [============================>.] - ETA: 0s - loss: 9.5987e-04 - mean_squared_error: 9.5987e-04
Epoch 00006: saving model to ../experiments/local-results/NAB/machine_temp/batch-32/NAB-machine_temp-48-12-6-fixedSigma-0.1/checkpoint/lstm/cp.ckpt
8932/8932 [==============================] - 6s 664us/sample - loss: 9.5950e-04 - mean_squared_error: 9.5950e-04 - val_loss: 9.3958e-04 - val_mean_squared_error: 9.3958e-04
Epoch 7/20
8864/8932 [============================>.] - ETA: 0s - loss: 9.3971e-04 - mean_squared_error: 9.3971e-04
Epoch 00007: saving model to ../experiments/local-results/NAB/machine_temp/batch-32/NAB-machine_temp-48-12-6-fixedSigma-0.1/checkpoint/lstm/cp.ckpt
8932/8932 [==============================] - 6s 656us/sample - loss: 9.4036e-04 - mean_squared_error: 9.4036e-04 - val_loss: 9.2072e-04 - val_mean_squared_error: 9.2072e-04
Epoch 8/20
8864/8932 [============================>.] - ETA: 0s - loss: 9.2281e-04 - mean_squared_error: 9.2281e-04
Epoch 00008: saving model to ../experiments/local-results/NAB/machine_temp/batch-32/NAB-machine_temp-48-12-6-fixedSigma-0.1/checkpoint/lstm/cp.ckpt
8932/8932 [==============================] - 6s 663us/sample - loss: 9.2169e-04 - mean_squared_error: 9.2169e-04 - val_loss: 9.0257e-04 - val_mean_squared_error: 9.0257e-04
Epoch 9/20
8864/8932 [============================>.] - ETA: 0s - loss: 9.0478e-04 - mean_squared_error: 9.0478e-04
Epoch 00009: saving model to ../experiments/local-results/NAB/machine_temp/batch-32/NAB-machine_temp-48-12-6-fixedSigma-0.1/checkpoint/lstm/cp.ckpt
8932/8932 [==============================] - 6s 654us/sample - loss: 9.0473e-04 - mean_squared_error: 9.0473e-04 - val_loss: 8.8796e-04 - val_mean_squared_error: 8.8796e-04
Epoch 10/20
8864/8932 [============================>.] - ETA: 0s - loss: 8.9285e-04 - mean_squared_error: 8.9285e-04
Epoch 00010: saving model to ../experiments/local-results/NAB/machine_temp/batch-32/NAB-machine_temp-48-12-6-fixedSigma-0.1/checkpoint/lstm/cp.ckpt
8932/8932 [==============================] - 6s 660us/sample - loss: 8.9289e-04 - mean_squared_error: 8.9289e-04 - val_loss: 8.7809e-04 - val_mean_squared_error: 8.7809e-04
Epoch 11/20
8864/8932 [============================>.] - ETA: 0s - loss: 8.8401e-04 - mean_squared_error: 8.8401e-04
Epoch 00011: saving model to ../experiments/local-results/NAB/machine_temp/batch-32/NAB-machine_temp-48-12-6-fixedSigma-0.1/checkpoint/lstm/cp.ckpt
8932/8932 [==============================] - 6s 658us/sample - loss: 8.8362e-04 - mean_squared_error: 8.8362e-04 - val_loss: 8.7047e-04 - val_mean_squared_error: 8.7047e-04
Epoch 12/20
8864/8932 [============================>.] - ETA: 0s - loss: 8.7461e-04 - mean_squared_error: 8.7461e-04
Epoch 00012: saving model to ../experiments/local-results/NAB/machine_temp/batch-32/NAB-machine_temp-48-12-6-fixedSigma-0.1/checkpoint/lstm/cp.ckpt
8932/8932 [==============================] - 6s 660us/sample - loss: 8.7509e-04 - mean_squared_error: 8.7509e-04 - val_loss: 8.6289e-04 - val_mean_squared_error: 8.6289e-04
Epoch 13/20
8864/8932 [============================>.] - ETA: 0s - loss: 8.6703e-04 - mean_squared_error: 8.6703e-04
Epoch 00013: saving model to ../experiments/local-results/NAB/machine_temp/batch-32/NAB-machine_temp-48-12-6-fixedSigma-0.1/checkpoint/lstm/cp.ckpt
8932/8932 [==============================] - 6s 667us/sample - loss: 8.6689e-04 - mean_squared_error: 8.6689e-04 - val_loss: 8.5333e-04 - val_mean_squared_error: 8.5333e-04
Epoch 14/20
8864/8932 [============================>.] - ETA: 0s - loss: 8.5853e-04 - mean_squared_error: 8.5853e-04
Epoch 00014: saving model to ../experiments/local-results/NAB/machine_temp/batch-32/NAB-machine_temp-48-12-6-fixedSigma-0.1/checkpoint/lstm/cp.ckpt
8932/8932 [==============================] - 6s 666us/sample - loss: 8.5915e-04 - mean_squared_error: 8.5915e-04 - val_loss: 8.4534e-04 - val_mean_squared_error: 8.4534e-04
Epoch 15/20
8864/8932 [============================>.] - ETA: 0s - loss: 8.5224e-04 - mean_squared_error: 8.5224e-04
Epoch 00015: saving model to ../experiments/local-results/NAB/machine_temp/batch-32/NAB-machine_temp-48-12-6-fixedSigma-0.1/checkpoint/lstm/cp.ckpt
8932/8932 [==============================] - 6s 657us/sample - loss: 8.5176e-04 - mean_squared_error: 8.5176e-04 - val_loss: 8.3922e-04 - val_mean_squared_error: 8.3922e-04
Epoch 16/20
8864/8932 [============================>.] - ETA: 0s - loss: 8.4424e-04 - mean_squared_error: 8.4424e-04
Epoch 00016: saving model to ../experiments/local-results/NAB/machine_temp/batch-32/NAB-machine_temp-48-12-6-fixedSigma-0.1/checkpoint/lstm/cp.ckpt
8932/8932 [==============================] - 6s 666us/sample - loss: 8.4529e-04 - mean_squared_error: 8.4529e-04 - val_loss: 8.3094e-04 - val_mean_squared_error: 8.3094e-04
Epoch 17/20
8864/8932 [============================>.] - ETA: 0s - loss: 8.3816e-04 - mean_squared_error: 8.3816e-04
Epoch 00017: saving model to ../experiments/local-results/NAB/machine_temp/batch-32/NAB-machine_temp-48-12-6-fixedSigma-0.1/checkpoint/lstm/cp.ckpt
8932/8932 [==============================] - 6s 658us/sample - loss: 8.3824e-04 - mean_squared_error: 8.3824e-04 - val_loss: 8.2518e-04 - val_mean_squared_error: 8.2518e-04
Epoch 18/20
8864/8932 [============================>.] - ETA: 0s - loss: 8.3225e-04 - mean_squared_error: 8.3225e-04
Epoch 00018: saving model to ../experiments/local-results/NAB/machine_temp/batch-32/NAB-machine_temp-48-12-6-fixedSigma-0.1/checkpoint/lstm/cp.ckpt
8932/8932 [==============================] - 6s 663us/sample - loss: 8.3169e-04 - mean_squared_error: 8.3169e-04 - val_loss: 8.1794e-04 - val_mean_squared_error: 8.1794e-04
Epoch 19/20
8864/8932 [============================>.] - ETA: 0s - loss: 8.2609e-04 - mean_squared_error: 8.2609e-04
Epoch 00019: saving model to ../experiments/local-results/NAB/machine_temp/batch-32/NAB-machine_temp-48-12-6-fixedSigma-0.1/checkpoint/lstm/cp.ckpt
8932/8932 [==============================] - 6s 655us/sample - loss: 8.2538e-04 - mean_squared_error: 8.2538e-04 - val_loss: 8.1092e-04 - val_mean_squared_error: 8.1092e-04
Epoch 20/20
8864/8932 [============================>.] - ETA: 0s - loss: 8.1935e-04 - mean_squared_error: 8.1935e-04
Epoch 00020: saving model to ../experiments/local-results/NAB/machine_temp/batch-32/NAB-machine_temp-48-12-6-fixedSigma-0.1/checkpoint/lstm/cp.ckpt
8932/8932 [==============================] - 6s 660us/sample - loss: 8.1929e-04 - mean_squared_error: 8.1929e-04 - val_loss: 8.0707e-04 - val_mean_squared_error: 8.0707e-04
(993, 11, 6)
jieran1234 commented 5 months ago

I have the same problem as you. For some reason, the VAE decoder reconstruction comes out basically near 0, which is a far cry from the original data. What is the reason for this? Has the issue been resolved?