PIL image normalization

username: snowe
cooked: <p>Hi everyone <img src="https://discuss.pytorch.org/images/emoji/apple/slight_smile.png?v=9" title=":slight_smile:" class="emoji" alt=":slight_smile:"></p>
<p>I am currently working on a CNN project and after looking at the PyTorch tutorial (<a href="https://pytorch.org/tutorials/beginner/blitz/cifar10_tutorial.html#" rel="noopener nofollow ugc">https://pytorch.org/tutorials/beginner/blitz/cifar10_tutorial.html#</a>) I have some questinos regarding normalization.</p>
<p>The tutorial mentions that since the PIL images are in range [0,1], they use a mean and standard deviation of 0.5 to bring them into a range of [-1,1]. I know that this is common practice (as is calculating the actual mean and standard deviation or keeping them in range [0,1]). But: not using the actual mean and standard deviation will not result in an overall mean of 0 and variance 1 as often desired, right?</p>
<p>Also: why bring the images in a range of [-1,1] in the first place? Does anyone have a paper or book explaining this (I need a reference for my project <img src="https://discuss.pytorch.org/images/emoji/apple/wink.png?v=9" title=":wink:" class="emoji" alt=":wink:"> )? All I can find is people saying that it’s common practice…</p>
<p>Any help is very much appreciated!</p>
<p>All the best<br>
snowe</p>

username: ptrblck
cooked: <aside class="quote no-group" data-username="snowe" data-post="1" data-topic="100411">
<div class="title">
<div class="quote-controls"></div>
<img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/s/e68b1a/48.png" class="avatar"> snowe:</div>
<blockquote>
<p>But: not using the actual mean and standard deviation will not result in an overall mean of 0 and variance 1 as often desired, right?</p>
</blockquote>
</aside>
<p>Yes, but the propsed method might still work “good enough” for the tutorial. <img src="https://discuss.pytorch.org/images/emoji/apple/wink.png?v=12" title=":wink:" class="emoji" alt=":wink:" loading="lazy" width="20" height="20"></p>
<aside class="quote no-group" data-username="snowe" data-post="1" data-topic="100411">
<div class="title">
<div class="quote-controls"></div>
<img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/s/e68b1a/48.png" class="avatar"> snowe:</div>
<blockquote>
<p>Does anyone have a paper or book explaining this (I need a reference for my project <img src="https://discuss.pytorch.org/images/emoji/apple/wink.png?v=12" title=":wink:" class="emoji" alt=":wink:" loading="lazy" width="20" height="20"> )?</p>
</blockquote>
</aside>
<p>I think you should be able to find a proper explaination in <a href="https://www.deeplearningbook.org/">Goodfellow et al., Deep Learning</a> and I’m sure <a href="https://www.microsoft.com/en-us/research/uploads/prod/2006/01/Bishop-Pattern-Recognition-and-Machine-Learning-2006.pdf">Bishop, Pattern Recognition and Machine Learning</a> explains it as well (which is also a general recommendation to take a look at).</p>

username: snowe
cooked: <p><a class="mention" href="/u/ptrblck">@ptrblck</a> Thank you so much! <img src="https://discuss.pytorch.org/images/emoji/apple/slight_smile.png?v=9" title=":slight_smile:" class="emoji" alt=":slight_smile:"></p>