Answers.Body: <p>Looking at the variable names in the code and considering the context, it seems to me that the author is using the word &quot;Lazy&quot; to describe the approach.  I believe the author actually means that a naïve approach to producing a grayscale image is being used.</p>
  <p>If you want to use a less-naïve approach, you might consider producing the dot product of the 3 channel color depth by a vector such as <code>[0.2126, 0.7153, 0.0722]</code> which will produce something a bit more accurate.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-01-19T11:49:47.047Z
Answers.LastActivityDate: 2022-01-19T11:49:47.047Z
Answers.UserDisplayName: David Hoelzer
Body: <p>Consider the following paragraph, taken from <em>3.4: Named Tensors</em> of the textbook named <a href="http://web.archive.org/web/20220113022756/https://pytorch.org/assets/deep-learning/Deep-Learning-with-PyTorch.pdf" rel="nofollow noreferrer"><strong>Deep Learning with PyTorch</strong></a> by <em>Eli Stevens et al.</em>, regarding the calculation of the mean for RGB channels of an RGB image in order to convert it into a grayscale image</p>
  <blockquote>
  <p>So sometimes the RGB channels are in dimension 0, and sometimes they
  are in dimension 1. But we can generalize by counting from the end:
  they are always in dimension –3, the third from the end. The <strong>lazy,
  unweighted mean</strong> can thus be written as follows:</p>
  <pre><code># In[4]:
  img_gray_naive = img_t.mean(-3)
  batch_gray_naive = batch_t.mean(-3)
  img_gray_naive.shape, batch_gray_naive.shape
  
  # Out[4]:
  (torch.Size([5, 5]), torch.Size([2, 5, 5]))
  </code></pre>
  </blockquote>
  <p>Here <code>img_t</code> is a single image tensor of shape <code>(3, 5, 5)</code> and <code>batch_t</code> is a batch of 2 images with the same shape. They are taking the mean over the channel dimension.</p>
  <p>Since they are taking the normal average of the intensity values over RGB channels, it is unweighted. But, what does it mean by lazy here? Are they referring to some implementation detail regarding lazy initialization? If yes, what exactly does it mean?</p>
  
Tags: <terminology><pytorch><image-processing><implementation><tensor>
Title: What does it mean by "lazy mean" here?
UserDisplayName: hanugm
ThreadText: # What does it mean by "lazy mean" here?
  
  (Asked by: username_0 on 2022-01-19)
  
  Consider the following paragraph, taken from 3.4: Named Tensors of the textbook named Deep Learning with PyTorch by Eli Stevens et al., regarding the calculation of the mean for RGB channels of an RGB image in order to convert it into a grayscale image
  
  So sometimes the RGB channels are in dimension 0, and sometimes they
  are in dimension 1. But we can generalize by counting from the end:
  they are always in dimension –3, the third from the end. The lazy,
  unweighted mean can thus be written as follows:
  # In[4]:
  img_gray_naive = img_t.mean(-3)
  batch_gray_naive = batch_t.mean(-3)
  img_gray_naive.shape, batch_gray_naive.shape
  
  # Out[4]:
  (torch.Size([5, 5]), torch.Size([2, 5, 5]))
  
  
  Here img_t is a single image tensor of shape (3, 5, 5) and batch_t is a batch of 2 images with the same shape. They are taking the mean over the channel dimension.
  Since they are taking the normal average of the intensity values over RGB channels, it is unweighted. But, what does it mean by lazy here? Are they referring to some implementation detail regarding lazy initialization? If yes, what exactly does it mean?
  
  **Tags:** terminology, pytorch, image-processing, implementation, tensor
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2022-01-19. Score: 2
  
  Looking at the variable names in the code and considering the context, it seems to me that the author is using the word "Lazy" to describe the approach. I believe the author actually means that a naïve approach to producing a grayscale image is being used.
  
  If you want to use a less-naïve approach, you might consider producing the dot product of the 3 channel color depth by a vector such as `[0.2126, 0.7153, 0.0722]` which will produce something a bit more accurate.
  
  
  ---
  
  