【发布时间】:2018-11-25 04:57:34
【问题描述】:
我正在使用变分自动编码器 (VAE) 来检测时间序列中的异常。到目前为止,我使用了这个 tut https://blog.keras.io/building-autoencoders-in-keras.html 和这个 https://wiseodd.github.io/techblog/2016/12/10/variational-autoencoder/。
不过,我在实施 VAE 时遇到了一些麻烦。 我有 77093 个样本,它们有 1 个维度。我使用 timesteps=100 进行预测。所以我重塑我的 x_train 如下:
x_train.shape = (77093, 100, 1)
型号:
inputs = Input(shape=(timesteps, input_dim))
encoded = LSTM(32)(inputs)
mu = Dense(1, activation='linear')(encoded)
log_sigma = Dense(1, activation='linear')(encoded)
z = Lambda(sample_z)([mu, log_sigma])
decoded = RepeatVector(timesteps)(z)
decoded = LSTM(1, return_sequences=True)(decoded)
decoded = LSTM(1)(decoded)
sequence_autoencoder = Model(inputs, decoded)
我的样本来自:
def sample_z(args):
mu, log_sigma = args
eps = K.random_normal(shape=(50, 1), mean=0., stddev=1.)
return mu + K.exp(log_sigma / 2) * eps
模型编译。但不知道对不对。
1.) 我不太了解 RepeatVector 层以及是否有必要重复我的示例 z。但是如果我不使用 RepeatVector 层,LSTM-Layer 会抛出一个错误,因为它需要一个 3 dim 的输入。
2.)我对潜在变量的降维并不感到不满。导致我的 In_dim=1。究竟减少了什么?
提前致谢。
【问题讨论】:
-
时间序列的 VAE LSTM:towardsdatascience.com/…
标签: keras deep-learning lstm autoencoder inference