我正在研究一个变分自动编码器 (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)
Run Code Online (Sandbox Code Playgroud)
该模型:
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)
Run Code Online (Sandbox Code Playgroud)
我从以下样本中取样:
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
Run Code Online (Sandbox Code Playgroud)
模型编译。但我不知道它是否正确。 …
我尝试使用对数缩放轴绘制 relplot。利用以前的答案,我尝试过:
import matplotlib.pyplot as plt
import seaborn as sns
f, ax = plt.subplots(figsize=(7, 7))
ax.set(xscale="log", yscale="log")
tips = sns.load_dataset("tips")
sns.relplot(x="total_bill", y="tip", hue='smoker', data=tips)
plt.show()
Run Code Online (Sandbox Code Playgroud)
然而,结果中的轴没有改变。
我该如何补救?