Answers.Body: <p>The purpose of rescaling  gradient descent problems is to reframe the problem for quicker convergence / calculation of linear coefficient parameters.  in the <a href="http://openclassroom.stanford.edu/MainFolder/VideoPage.php?course=MachineLearning&amp;video=03.1-LinearRegressionII-FeatureScaling&amp;speed=100" rel="nofollow noreferrer">Stanford video</a> series, Andrew Ng provides a intuitive explanation and enables one to hone an intuitive understanding.</p>
  
  <p>Multivariate input regression gradient descent converges faster when the inputs are in the same order of magnitude.  For example, if predicting house prices based on X1= the number of rooms and X2= area of the home in square feet.  X1 is on scale of 0-6 bedrooms and and X2 is typically 1000-3000 square feet.  Given the diffence in magnitude, this problem is a good candidate for feature scaling.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-11-21T06:42:24.283Z
Answers.LastActivityDate: 2018-11-21T06:48:18.023Z
Answers.LastEditDate: 2018-11-21T06:48:18.023Z
Answers.UserDisplayName: gatorback
Answers.Body: <p>T'is easy, but misunderstood. What they mean is to map it from the range of 0-255 to the range of 0-1. This means that 0 would be 0, and 255 would be 1. 
  The code for this is as such in javascript:</p>
  
  <pre><code>function map (num, in_min, in_max, out_min, out_max) {
    return (num - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
  }
  </code></pre>
  
  <p>Use the function, like this:</p>
  
  <pre><code>var num = 5;
  console.log(map(num, 0, 255, 0, 1)); // 0.0196078431372549
  var num = 150
  console.log(map(num, 0, 255, 0, 1)); // 0.5882352941176471
  </code></pre>
  
  <p>Iterate over the entire image, and use the function (or you programming languages equivalent) on every egg or each pixel.
  By doing so, all values are in the 0,1 interval. Next, all you have to do is to feed it to the network.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-06-25T07:17:56.697Z
Answers.Text: thanks for your explanation it's quite clear now, but why need to do this step for
Answers.UserDisplayName: f.c
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-06-25T08:05:04.220Z
Answers.Text: Or simply divide by 255.0
Answers.UserDisplayName: pasaba por aqui
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-06-25T02:17:51.820Z
Answers.LastActivityDate: 2018-06-25T02:17:51.820Z
Answers.UserDisplayName: FreezePhoenix
Body: <p>I am a deep learning beginner recently reading this book "Deep learning with Python", the example explains the process of implementing a greyscale image classification using MNIST in keras, in the compilation step, it said,</p>
  
  <blockquote>
    <p>Before training, we’ll preprocess the data by reshaping it into the shape the network expects and scaling it so that all values are in the [0, 1] interval. Previously, our training images, for instance, were stored in an array of shape (60000, 28, 28) of type uint8 with values in the [0, 255] interval. We transform it into a float32 array of shape (60000, 28 * 28) with values between 0 and 1.</p>
  </blockquote>
  
  <p>Images stored in an array of shape (60000, 28, 28) of type uint8 with values in the [0, 255] interval. For my understanding, the values are between 0-255 of each px and storied as 3D matrix. Can someone explain why needs to "transform" it into the network expects by scaling it and make "all values are in the [0, 1]interval."?</p>
  
  <p>Please also make suggestions if I didn't explain some parts correctly.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-06-25T07:55:10.427Z
Comments.Text: It is not mandatory to rescale from [0,255] to [0,1]. Instead, first layer of the NN can adjust its weights. It is the same a value in range [0,255] with w=0.01 than a value in range [0,1] with w=2.55. Rescale is only mandatory if the NN implementation has some restrictions in the input values.
Comments.UserDisplayName: pasaba por aqui
Tags: <neural-networks><machine-learning><deep-learning><convolutional-neural-networks>
Title: What is the purpose of "reshaping it into the shape the network expects and scaling it so that all values are in the [0, 1] interval."?
UserDisplayName: f.c
ThreadText: # What is the purpose of "reshaping it into the shape the network expects and scaling it so that all values are in the [0, 1] interval."?
  
  (Asked by: username_0 on 2018-06-24)
  
  I am a deep learning beginner recently reading this book "Deep learning with Python", the example explains the process of implementing a greyscale image classification using MNIST in keras, in the compilation step, it said,
  
  > Before training, we’ll preprocess the data by reshaping it into the shape the network expects and scaling it so that all values are in the [0, 1] interval. Previously, our training images, for instance, were stored in an array of shape (60000, 28, 28) of type uint8 with values in the [0, 255] interval. We transform it into a float32 array of shape (60000, 28 \* 28) with values between 0 and 1.
  
  Images stored in an array of shape (60000, 28, 28) of type uint8 with values in the [0, 255] interval. For my understanding, the values are between 0-255 of each px and storied as 3D matrix. Can someone explain why needs to "transform" it into the network expects by scaling it and make "all values are in the [0, 1]interval."?
  
  Please also make suggestions if I didn't explain some parts correctly.
  
  **Tags:** neural-networks, machine-learning, deep-learning, convolutional-neural-networks
  > **Comments:**
  > **username_1**: It is not mandatory to rescale from [0,255] to [0,1]. Instead, first layer of the NN can adjust its weights. It is the same a value in range [0,255] with w=0.01 than a value in range [0,1] with w=2.55. Rescale is only mandatory if the NN implementation has some restrictions in the input values.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2018-11-21. Score: 1
  
  The purpose of rescaling gradient descent problems is to reframe the problem for quicker convergence / calculation of linear coefficient parameters. in the [Stanford video](http://openclassroom.stanford.edu/MainFolder/VideoPage.php?course=MachineLearning&video=03.1-LinearRegressionII-FeatureScaling&speed=100) series, Andrew Ng provides a intuitive explanation and enables one to hone an intuitive understanding.
  
  Multivariate input regression gradient descent converges faster when the inputs are in the same order of magnitude. For example, if predicting house prices based on X1= the number of rooms and X2= area of the home in square feet. X1 is on scale of 0-6 bedrooms and and X2 is typically 1000-3000 square feet. Given the diffence in magnitude, this problem is a good candidate for feature scaling.
  
  
  ---
  
  ### Answer by username_3 on 2018-06-25. Score: 0
  
  T'is easy, but misunderstood. What they mean is to map it from the range of 0-255 to the range of 0-1. This means that 0 would be 0, and 255 would be 1. 
  The code for this is as such in javascript:
  function map (num, in_min, in_max, out_min, out_max) {
    return (num - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
  }
  
  Use the function, like this:
  var num = 5;
  console.log(map(num, 0, 255, 0, 1)); // 0.0196078431372549
  var num = 150
  console.log(map(num, 0, 255, 0, 1)); // 0.5882352941176471
  
  Iterate over the entire image, and use the function (or you programming languages equivalent) on every egg or each pixel.
  By doing so, all values are in the 0,1 interval. Next, all you have to do is to feed it to the network.
  
  > **Comments:**
  > **username_0**: thanks for your explanation it's quite clear now, but why need to do this step for  
  > **username_1**: Or simply divide by 255.0  
  
  ---
  
  