归一化为[0,1]与[-1,1] [英] Normalizing to [0,1] vs [-1,1]

查看:947
本文介绍了归一化为[0,1]与[-1,1]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经阅读了一些有关使用神经网络进行关键点检测的教程.我注意到,对于输入(图像),除以255非常普遍(归一化为[0,1],因为值介于0到255之间).但是我注意到,对于目标(X/Y)坐标,标准化为[-1,1]更为常见.造成这种差异的任何原因.

I've been going through a few tutorials on using neural networks for key points detection. I've noticed that for the inputs (images) it's very common to divide by 255 (normalizing to [0,1] since values fall between 0 and 255). But for the targets (X/Y) coordinates I've noticed it's more common to normalize to [-1,1]. Any reason for this disparity.

示例: http://danielnouri.org/notes/2014/12/17/using-convolutional-neural-nets-to-detect-facial-keypoints-tutorial/

X = np.vstack(df['Image'].values) / 255.  # scale pixel values to [0, 1]
y = (y - 48) / 48  # scale target coordinates to [-1, 1]

推荐答案

根据我的说法,从技术上讲,在标准化值方面应该没有太大差异.

According to me, technically there should not be much of a difference on how you are normalising the values.

但是这些东西对机器学习技术很重要.

But these things matter in ML techniques.

将像素范围从(0到255)标准化为(0到1),可以使收敛速度更快.您也可以在-1和1之间进行选择.我已经在很多问题中使用了这个范围.而且没有这样的问题.

Normalising the pixel range from (0 to 255 ) to (0 to 1) makes the convergence rate faster. Here you can do ranging between -1 and 1 as well. I have used this range in lot of problems. And there are no as such issues.

但是对于输出而言,它有点棘手.由于使用的激活功能,使用0到1范围不是一个更好的主意. ReLU是max(0,x),当您也提供负值时,它会更好地工作.这就是relu的全部重点. tanh的值也介于-1和1之间.唯一剩下的选择是使用Sigmoid函数,该函数与relu和tanh函数相比效果不佳.乙状结肠的问题是梯度消失,并且不是零中心的,这为权重提供了锯齿状的锯齿状梯度更新.您可以在此处查找.

But for the output it is little tricky. Using range 0 to 1 is not a better idea because of the activation function you are using. ReLU is max(0, x) which works better when you provide negative values as well. That is the whole point of relu. Also tanh ranges values between -1 and 1. The only choice you are left with is to use sigmoid function which does not perform that well compared to relu and tanh functions. The problem with sigmoid is of vanishing gradient and it is not zero centered which gives somewhat zig zagged gradient updates for the weights. You can look for it here.

这篇关于归一化为[0,1]与[-1,1]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆