小编Laf*_*tte的帖子

在 Keras 中使用 LSTM 对时间序列进行变分自动编码器

我正在研究一个变分自动编码器 (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)

模型编译。但我不知道它是否正确。 …

inference autoencoder deep-learning lstm keras

5
推荐指数
1
解决办法
6669
查看次数

如何对seaborn relplot的轴使用对数刻度?

我尝试使用对数缩放轴绘制 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)

然而,结果中的轴没有改变。

在此处输入图片说明

我该如何补救?

python matplotlib seaborn

2
推荐指数
2
解决办法
774
查看次数