精度指标在 Keras 的样本去噪自动编码器中意味着什么?
What Does Accuracy Metrics Mean in Keras' Sample Denoising Autoencoder?
我正在使用 Keras 的样本去噪自动编码器;
https://keras.io/examples/mnist_denoising_autoencoder/
在编译时,我使用了以下选项:
autoencoder.compile(loss='mse', optimizer= Adadelta, metrics=['accuracy'])
接着是培训。我在不使用嘈杂训练的情况下故意进行了训练 data(x_train_noisy)
,但只是试图恢复 x_train
。
autoencoder.fit(x_train, x_train, epochs=30, batch_size=128)
在训练了 60,000 个 MNIST 数字输入后,它给我的准确率为 81.25%。这是否意味着有 60000*81.25% 的图像被 PERFECTLY 恢复(等于原始输入逐像素),也就是说,自编码器的 81.25% 输出图像是 IDENTICAL 与其输入对应物相同,还是其他?
此外,我还通过逐像素比较输出和原始数据(60000个28X28矩阵)进行了手动检查——从它们的差异中计算非零元素:
x_decoded = autoencoder.predict(x_train)
temp = x_train*255
x_train_uint8 = temp.astype('uint8')
temp = x_decoded*255
x_decoded_uint8 = temp.astype('uint8')
c = np.count_nonzero(x_train_uint8 - x_decoded_uint8)
cp = 1-c /60000/28/28
然而cp只有71%左右。谁能告诉我为什么会有差异?
准确性对于回归问题没有意义,因此 keras 示例在 autoencoder.compile 期间不使用该指标。
在这种情况下,keras 会根据此指标计算准确度。
def binary_accuracy(y_true, y_pred):
return K.mean(K.equal(y_true, K.round(y_pred)), axis=-1)
使用此 numpy 实现,您应该获得与 Keras 输出相同的值以在训练结束时验证准确性。
x_decoded = autoencoder.predict(x_test_noisy)
acc = np.mean(np.equal(x_test, np.round(x_decoded)))
print(acc)
更多详情请参考此答案:
我正在使用 Keras 的样本去噪自动编码器; https://keras.io/examples/mnist_denoising_autoencoder/
在编译时,我使用了以下选项:
autoencoder.compile(loss='mse', optimizer= Adadelta, metrics=['accuracy'])
接着是培训。我在不使用嘈杂训练的情况下故意进行了训练 data(x_train_noisy)
,但只是试图恢复 x_train
。
autoencoder.fit(x_train, x_train, epochs=30, batch_size=128)
在训练了 60,000 个 MNIST 数字输入后,它给我的准确率为 81.25%。这是否意味着有 60000*81.25% 的图像被 PERFECTLY 恢复(等于原始输入逐像素),也就是说,自编码器的 81.25% 输出图像是 IDENTICAL 与其输入对应物相同,还是其他?
此外,我还通过逐像素比较输出和原始数据(60000个28X28矩阵)进行了手动检查——从它们的差异中计算非零元素:
x_decoded = autoencoder.predict(x_train)
temp = x_train*255
x_train_uint8 = temp.astype('uint8')
temp = x_decoded*255
x_decoded_uint8 = temp.astype('uint8')
c = np.count_nonzero(x_train_uint8 - x_decoded_uint8)
cp = 1-c /60000/28/28
然而cp只有71%左右。谁能告诉我为什么会有差异?
准确性对于回归问题没有意义,因此 keras 示例在 autoencoder.compile 期间不使用该指标。
在这种情况下,keras 会根据此指标计算准确度。
def binary_accuracy(y_true, y_pred):
return K.mean(K.equal(y_true, K.round(y_pred)), axis=-1)
使用此 numpy 实现,您应该获得与 Keras 输出相同的值以在训练结束时验证准确性。
x_decoded = autoencoder.predict(x_test_noisy)
acc = np.mean(np.equal(x_test, np.round(x_decoded)))
print(acc)
更多详情请参考此答案: