我在MATLAB中创建了一个自动编码器神经网络.我在第一层有很大的输入,我必须通过网络的输出层重建.我不能使用大输入,所以我使用sigmfMATLAB的功能将其转换为[0,1]之间.对于所有大值,它给出的值为1.000000.我尝试过使用设置格式,但没有用.
有自动编码器使用大值的解决方法吗?
我在做Keras库作者写的卷积自编码器教程:https ://blog.keras.io/building-autoencoders-in-keras.html
但是,当我启动完全相同的代码,并使用 summary() 分析网络架构时,似乎输出大小与输入大小不兼容(在自动编码器的情况下是必需的)。这是summary()的输出:
**____________________________________________________________________________________________________
Layer (type) Output Shape Param # Connected to
====================================================================================================
input_1 (InputLayer) (None, 1, 28, 28) 0
____________________________________________________________________________________________________
convolution2d_1 (Convolution2D) (None, 16, 28, 28) 160 input_1[0][0]
____________________________________________________________________________________________________
maxpooling2d_1 (MaxPooling2D) (None, 16, 14, 14) 0 convolution2d_1[0][0]
____________________________________________________________________________________________________
convolution2d_2 (Convolution2D) (None, 8, 14, 14) 1160 maxpooling2d_1[0][0]
____________________________________________________________________________________________________
maxpooling2d_2 (MaxPooling2D) (None, 8, 7, 7) 0 convolution2d_2[0][0]
____________________________________________________________________________________________________
convolution2d_3 (Convolution2D) (None, 8, 7, 7) 584 maxpooling2d_2[0][0]
____________________________________________________________________________________________________
maxpooling2d_3 (MaxPooling2D) (None, 8, 3, 3) 0 convolution2d_3[0][0]
____________________________________________________________________________________________________
convolution2d_4 (Convolution2D) …Run Code Online (Sandbox Code Playgroud) 在下面的代码中,他们使用自动编码器作为监督聚类或分类,因为它们具有数据标签. http://amunategui.github.io/anomaly-detection-h2o/ 但是,如果我没有标签,我可以使用自动编码器对数据进行聚类吗?问候
我正在尝试使用 Keras 为文本序列构建字符级自动编码器。当我编译模型时,我收到一个关于张量形状的错误,如下所示。我打印了层规格来检查,如果张量形状匹配,我发现问题可能出在最后一个 Lambda 层没有正确指定输出张量形状,但我不知道为什么不正确或如何指定它并没有在 Keras 或 Google 的文档中找到任何关于它的信息。
错误输出下面也是代码的一部分,我在这里定义了我的模型。如果需要,用于澄清的整个脚本在这里:PasteBin。
(主要注意最后一层。)
0 <keras.engine.topology.InputLayer object at 0x7f5d290eb588> Input shape (None, 80) Output shape (None, 80)
1 <keras.layers.core.Lambda object at 0x7f5d35f25a20> Input shape (None, 80) Output shape (None, 80, 99)
2 <keras.layers.core.Dense object at 0x7f5d2dda52e8> Input shape (None, 80, 99) Output shape (None, 80, 256)
3 <keras.layers.core.Dropout object at 0x7f5d25004da0> Input shape (None, 80, 256) Output shape (None, 80, 256)
4 <keras.layers.core.Dense object at 0x7f5d2501ac18> Input shape …Run Code Online (Sandbox Code Playgroud) 我正在尝试在 Keras 中构建一个文本 LSTM 自动编码器。我想使用嵌入层,但我不确定如何实现。代码看起来像这样。
inputs = Input(shape=(timesteps, input_dim))
embedding_layer = Embedding(numfeats + 1,
EMBEDDING_DIM,
weights=[data_gen.get_embedding_matrix()],
input_length=maxlen,
trainable=False)
embedded_sequence = embedding_layer(inputs)
encoded = LSTM(num_units)(inputs)
decoded = RepeatVector(timesteps)(encoded)
decoded = LSTM(???, return_sequences=True)(decoded)
sequence_autoencoder = Model(inputs, decoded)
sequence_autoencoder.compile(loss='binary_crossentropy', optimizer='adam')
Run Code Online (Sandbox Code Playgroud)
我不确定如何将输出解码为目标序列(这显然是输入序列)。
我有这个自动编码器:
input_dim = Input(shape=(10,))
encoded1 = Dense(30, activation = 'relu')(input_dim)
encoded2 = Dense(20, activation = 'relu')(encoded1)
encoded3 = Dense(10, activation = 'relu')(encoded2)
encoded4 = Dense(6, activation = 'relu')(encoded3)
decoded1 = Dense(10, activation = 'relu')(encoded4)
decoded2 = Dense(20, activation = 'relu')(decoded1)
decoded3 = Dense(30, activation = 'relu')(decoded2)
decoded4 = Dense(ncol, activation = 'sigmoid')(decoded3)
autoencoder = Model(input = input_dim, output = decoded4)
autoencoder.compile(-...)
autoencoder.fit(...)
Run Code Online (Sandbox Code Playgroud)
现在我想打印或保存在编码4中生成的功能。基本上,从一个巨大的数据集开始,我想在训练部分之后提取自动编码器生成的特征,以获得我的数据集的受限表示。
你可以帮帮我吗?
我正在使用 Keras 构建一个变分自动编码器。我很大程度上受到@Fchollet 示例的启发:https : //github.com/fchollet/keras/blob/master/examples/variational_autoencoder.py
但我正在处理连续数据。我的输出是一个持续时间,而不是像 MNIST 那样对数字进行排名。在这方面,我将损失函数从 binary_crossentropy 更改为 mean_squared_error。我主要想知道第二项,即 KL 散度。它应该适用于连续数据吗?我无法绕过它。对我来说,它应该将相似的数据紧密地放在潜在空间中。例如,在 MNIST 数据的 cas 中,将每个“1”放在潜在空间中,将每个“2”放在一起等等......因为我正在处理连续数据,它是如何工作的?在我的情况下有更好的丢失功能吗?
这是丢失的功能:
def vae_loss(x, x_decoded_mean):
xent_loss = original_dim *metrics.mean_squared_error(x, x_decoded_mean)
kl_loss = - 0.5 * K.mean(1 + z_log_sigma - K.square(z_mean) - K.exp(z_log_sigma), axis=-1)
return K.mean(xent_loss + kl_loss)
vae.compile(optimizer='Adam', loss=vae_loss)
Run Code Online (Sandbox Code Playgroud)
如您所见,一些类似的数据会根据需要放在一起。当我将 kl_loss 函数的系数增加到 "-100000" 而不是 "-0.5" 时会发生以下情况:

我以为我会以几乎线性的方式从蓝色变为红色。相反,我以混乱的方式获得了所有数据的集群。
你们能帮帮我吗?谢谢 !
我目前正在尝试实现一种LSTM自动编码器,以便将事务时间序列(Berka数据集)压缩为较小的编码向量。我正在使用的数据看起来像这样 (这是单个帐户在整个时间内的累计余额)。
我决定使用Keras,并尝试按照本教程创建一个简单的自动编码器。该模型不起作用。
我的代码是这样的:
import keras
from keras import Input, Model
from keras.layers import Lambda, LSTM, RepeatVector
from matplotlib import pyplot as plt
from scipy import io
from sklearn.preprocessing import MinMaxScaler
import numpy as np
class ResultPlotter(keras.callbacks.Callback):
def on_epoch_end(self, epoch, logs={}):
plt.subplots(2, 2, figsize=(10, 3))
indexes = np.random.randint(datapoints, size=4)
for i in range(4):
plt.subplot(2, 2, i+1)
plt.plot(sparse_balances[indexes[i]])
result = sequence_autoencoder.predict(sparse_balances[0:1])
plt.plot(result.T)
plt.xticks([])
plt.yticks([])
plt.tight_layout()
plt.show()
return
result_plotter = ResultPlotter()
sparse_balances = io.mmread("my_path_to_sparse_balances.mtx")
sparse_balances = sparse_balances.todense()
scaler = …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 fast.ai 版本 1.0.52 构建一个自动编码器,并且正在努力解决如何将标签设置为与原始图像相等的问题。我正在关注这篇博文:https : //alanbertl.com/autoencoder-with-fast-ai/
我用 ImageList 替换了原始代码中的 ImageItemList,因为它在最新的 fastai 版本中发生了变化。
%reload_ext autoreload
%autoreload 2
%matplotlib inline
from fastai.imports import *
from fastai.vision import *
from fastai.data_block import *
from fastai.basic_train import *
import pandas as pd
x = np.random.randint(256, size=(1000, 16384))
x = x/255
x = x.reshape(-1,128,128)
x = np.stack([x,x,x],1)
x.shape
class ArraysImageList(ImageList,FloatList):
def __init__(self, items:Iterator, log:bool=False, **kwargs):
if isinstance(items, ItemList):
items = items.items
super(FloatList,self).__init__(items,**kwargs)
def get(self,i):
return Tensor(super(FloatList,self).get(i).astype('float32'))
x_il = ArraysImageList(x)
x_ils = x_il.split_by_rand_pct()
lls …Run Code Online (Sandbox Code Playgroud) 我有我的数据DataFrame:
dOpen dHigh dLow dClose dVolume day_of_week_0 day_of_week_1 ... month_6 month_7 month_8 month_9 month_10 month_11 month_12
639 -0.002498 -0.000278 -0.005576 -0.002228 -0.002229 0 0 ... 0 0 1 0 0 0 0
640 -0.004174 -0.005275 -0.005607 -0.005583 -0.005584 0 0 ... 0 0 1 0 0 0 0
641 -0.002235 0.003070 0.004511 0.008984 0.008984 1 0 ... 0 0 1 0 0 0 0
642 0.006161 -0.000278 -0.000281 -0.001948 -0.001948 0 1 ... 0 0 1 0 0 …Run Code Online (Sandbox Code Playgroud) autoencoder ×10
keras ×6
python ×6
lstm ×3
fast-ai ×1
h2o ×1
lambda ×1
matlab ×1
python-3.x ×1
pytorch ×1