小编nas*_*ser的帖子

Keras自动编码器简单的例子有一个奇怪的输出

我正在尝试运行一个简单的自动编码器,所有的训练输入都是一样的.训练数据特征等于3,隐藏层中有3个节点.我用该输入训练自动编码器,然后我再次尝试预测它(编码/解码)(所以如果自动编码器按原样传递一切而没有任何改变它应该工作)

无论如何,情况并非如此,我有点难以理解为什么.我不确定我的代码或者我对autoencdoer实现的理解是否有问题.这是代码供参考.

PS我玩了多个epoches,训练集中的例子数量,批量大小,使训练数据值在0-1之间,并且跟踪损失值,但这也没有帮助.

`

from keras.layers import Input, Dense
from keras.models import Model
import numpy as np 
# this is the size of our encoded representations
encoding_dim = 3

x_train=np.array([[1,2,3],[1,2,3],[1,2,3],[1,2,3],[1,2,3],[1,2,3],[1,2,3],[1,2,3],[1,2,3]])
in= Input(shape=(3,))
encoded = Dense(encoding_dim, activation='relu')(in)
decoded = Dense(3, activation='sigmoid')(encoded)

# this model maps an input to its reconstruction
autoencoder = Model(in, decoded)
autoencoder.compile(optimizer='adadelta', loss='mse')

autoencoder.fit(x_train, x_train,
                epochs=100,
                batch_size=4)
autoencoder.predict(x_train)
Run Code Online (Sandbox Code Playgroud)

`

我得到的输出应该与输入相同(或至少接近),但我得到了这个)

`Out[180]: 
array([[ 0.80265796,  0.89038897,  0.9100889 ],
       [ 0.80265796,  0.89038897,  0.9100889 ],
       [ 0.80265796,  0.89038897,  0.9100889 ],
       ..., 
       [ …
Run Code Online (Sandbox Code Playgroud)

python autoencoder deep-learning keras

3
推荐指数
1
解决办法
2067
查看次数

标签 统计

autoencoder ×1

deep-learning ×1

keras ×1

python ×1