Tensorflow:我的损失函数产生巨大的数字

cos*_*sst 3 image-processing neural-network autoencoder deep-learning tensorflow

我正在尝试使用神经网络进行图像修复,并使用去噪自动编码器预先训练权重。全部根据https://papers.nips.cc/paper/4686-image-denoising-and-inpainting-with-deep-neural-networks.pdf

我已经制作了他们正在使用的自定义损失函数。

我的集合是图像的一批重叠补丁 (196x32x32)。我的输入是损坏的图像批次,输出应该是清理后的图像。

我的损失函数的一部分是

dif_y = tf.subtract(y_xi,y_)

dif_norm = tf.norm(dif_y, ord = 'euclidean', axis = (1,2))
Run Code Online (Sandbox Code Playgroud)

其中 y_xi(196 x 1 x 3072) 是重建的干净图像,y_ (196 x 1 x 3072) 是真实的干净图像。所以我实际上从损坏的版本中减去所有图像,然后将所有这些差异相加。我觉得这个数字很大很正常。

train_step = tf.train.AdamOptimizer().minimize(loss)
Run Code Online (Sandbox Code Playgroud)

损失值开始于 3*10^7 左右,并在 200 次运行(我循环 1000 次)后收敛于接近值。所以我的输出图像将与原始图像相差数英里。

编辑:从 3.02391e+07 开始并收敛到 3.02337e+07

有什么办法我的损失值是正确的吗?如果是这样,我怎样才能大幅减少它?

谢谢

编辑2:我的损失函数

dif_y = tf.subtract(y,y_)
dif_norm = tf.norm(dif_y, ord = 'euclidean', axis = (1,2))
sqr_norm = tf.square(dif_norm)
prod = tf.multiply(sqr_norm,0.5)
sum_norm2 = tf.reduce_sum(prod,0)
error_1 = tf.divide(sum_norm2,196)
Run Code Online (Sandbox Code Playgroud)

cos*_*sst 5

如果其他人也有类似的问题,仅供记录:请记住标准化您的数据!我实际上是从 [0,255] 范围内的值减去 [0,1] 范围内的值。非常幼稚的错误,我经过惨痛的教训才学会的!

Input values / 255

Expected values / 255

问题解决了。