TimyadNyda / Variational-Lstm-Autoencoder

Lstm variational auto-encoder for time series anomaly detection and features extraction
MIT License
311 stars 61 forks source link

What is the meaning of the -1 in df = df.reshape(-1,timesteps,n_dim) #use 3D input, n_dim = 1 for 1D time series. #9

Closed JinYang88 closed 3 years ago

JinYang88 commented 3 years ago

What is the meaning of the -1 in df = df.reshape(-1,timesteps,n_dim) #use 3D input, n_dim = 1 for 1D time series?

Thanks!

TimyadNyda commented 3 years ago

Hello,

When you reshape an array into n dimensions, you only need to specify n-1 dimensions, the remaining one will be automatically computed (when you set -1).

m = df or np array m.shape = (10,20) m.reshape(10, 10, 2) == m.reshape(-1, 10, 2) == m.reshape(10,-1,2) == m.reshape(10,10,-1)

Cheers.

JinYang88 commented 3 years ago

Thanks, that is really helpful!