简体   繁体   中英

Autoencoder using MLP for anomaly detection in multivariate timeseries

I am developing an autoencoder using an MLP to detect anomalies in a multivariate time series. To simplify the problem, I started using only one series variable.

Univariate case

The way I'm applying it is to break the time series into pieces, and present those pieces to the network. For example, my series consists of 1000 points, which I break into 50 subseries of length 20. Each of these subseries becomes an example for learning the network.

What should the DAE input_shape be? I saw that there is a difference if shape=(20, ) and shape=(20,1) . I leave below the code of the DAE that I have been working on. And how should the format of the last layer of the DAE be? When I use the output layer with only 1 neuron, the model works correctly, why?

model = keras.Sequential([

        ### ENCODING ###
        layers.Input(shape=(df_train.shape[1], df_train.shape[2])),
       # or ?
       #layers.Input(shape=(df_train.shape[1],)),

        layers.Dense(16, activation='sigmoid'),
        layers.Dropout(rate=0.1),                     
        layers.Dense(8, activation='sigmoid'),

        ### LATENT SPACE
        layers.Dense(4, activation='sigmoid'),

        ### DECODING ###
        layers.Dense(8, activation='sigmoid'),
        layers.Dropout(rate=0.1),               
        layers.Dense(16, activation='sigmoid'),
     
        layers.Dense(1, activation='sigmoid')

]) 

Multivariate case

Considering the multivariate case, in which I have 16 time series. How would the input shape and output layer look?

Dense layers, the building block of an MPL, only take a single dimension. So you must flatten your 2D vector into 1D. The shape of the vector will (width*height,) .

The alternative is to use a Convolutional or Recurrent Autoencoder (LSTM/GRU). With a convolutional autoencoder, most of the layers will be either Conv2d or Conv1d. Then you would use a single Dense layer as the compressive bottleneck. Convolutional layers take inputs on shape (width,height,channel) - where channel can be 1 if there is no third dimension.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM