【发布时间】:2020-12-13 23:11:15
【问题描述】:
我正在使用自动编码器作为一种降维技术,将学习到的表示用作可用于进一步分析的低维特征。
代码sn-p:
# Note: implementation --> based on keras
encoding_dim = 32
# Define input layer
X_input = Input(shape=(X_train.shape[1],))
# Define encoder:
encoded = Dense(encoding_dim, activation='relu')(X_input)
# Define decoder:
decoded = Dense(X_train.shape[1], activation='sigmoid')(encoded)
# Create the autoencoder model
AE_model = Model(X_input, decoded)
#Compile the autoencoder model
AE_model.compile(optimizer='adam', loss='mse')
#Extract learned representation
learned_feature = Model(X_input, encoded)
history = AE_model.fit(X_train, X_train, epochs=10, batch_size=32)
我一直在寻找一种方法来衡量学习表示的质量。我发现一种方法是测量重建误差。我使用以下代码:
import math
reconstr_error = AE_model.evaluate(X_train, X_train, verbose=0)
print('The reconstruction error: %.2f MSE (%.2f RMSE)' % (reconstr_error , math.sqrt(reconstr_error )))
我得到了 0.00 MSE (0.05 RMSE) 作为结果。但是,我不确定上面的代码在测量重构误差方面是否正确? 另外,如果有其他方法可以做到这一点,请告诉我。
【问题讨论】:
-
您输入的维度是多少?可能是你的压缩不够。另外,您在训练期间的损失是多少?
-
感谢您的回复,维度在113左右,损失是“mse - 均方误差”。
-
你在训练过程中得到了什么mse值?
-
我得到了 (0.0081)。我只是想知道我用来计算重构误差的方法是否正确。
-
这样做会得到什么
print('The reconstruction error: %.6f MSE (%.6f RMSE)' % (reconstr_error , math.sqrt(reconstr_error )))
标签: python machine-learning neural-network autoencoder dimensionality-reduction