Body: <p>Consider the following method <a href="https://pytorch.org/docs/stable/generated/torch.nn.Module.html" rel="nofollow noreferrer">related to buffers</a> in PyTorch</p>
  <pre><code>buffers(recurse=True)
  
  Returns an iterator over module buffers.
  
  Parameters
  
      recurse (bool) – if True, then yields buffers of this module and all submodules. Otherwise, yields only buffers that are direct members of this module.
  
  Yields
  
      torch.Tensor – module buffer
  </code></pre>
  <p><em><code>buffers()</code></em> is a method used for models (say neural networks) in PyTorch. <em><code>model.buffers()</code></em> contains the tensors related to the model and you can see it from the example provided below.</p>
  <pre><code>&gt;&gt;&gt; for buf in model.buffers():
  &gt;&gt;&gt;     print(type(buf), buf.size())
  &lt;class 'torch.Tensor'&gt; (20L,)
  &lt;class 'torch.Tensor'&gt; (20L, 1L, 5L, 5L)
  </code></pre>
  <p>The following method informs that a model in PyTorch has both parameters and buffers. So, buffers cannot be the same as the parameters (say weights) of the model.</p>
  <pre><code> cpu()
  
      Moves all model parameters and buffers to the CPU.
  </code></pre>
  <p>I am not aware of any numbers to store for a model other than its parameters. So, I have no idea what buffers of a model in the PyTorch store. But, this implies that there are some other numbers related to a model that needs to be stored for efficiency or other purposes.</p>
  <p>Is it PyTorch specific? Else, what are those numbers, other than parameters, that need to be stored for a model?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-07-28T21:19:17.447Z
Comments.Text: This question seems to be about an API and not strictly related to AI, although you probably thought that a "buffer" was something special in AI (but I don't think it is, i.e. a buffer is just some data structure that holds something in PyTorch: see [this discussion](https://discuss.pytorch.org/t/what-pytorch-means-by-buffers/120266)), so I think it's off-topic. So, if you also think this is a programming question, I will close it as off-topic. Feel free to provide an answer to this question before I close it, if you think this post could be useful in the future.
Comments.UserDisplayName: nbro
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-07-28T21:48:06.500Z
Comments.Text: @nbro The question is not about buffer. The question is about what do buffer store.Buffer is a tensor and stores numbers related to a neural network. I am asking about those numbers and their nature.
Comments.UserDisplayName: hanugm
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-07-28T21:50:01.823Z
Comments.Text: I think this is still a programming question, as you're asking about the API and how it works. In PyTorch, apparently, these buffers can store some statistics (according to the link above), but this is not strictly related to AI.
Comments.UserDisplayName: nbro
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-07-28T21:56:51.407Z
Comments.Text: If I ask **Are there any numbers to store other than parameters of a model?** then will it be okay? @nbro
Comments.UserDisplayName: hanugm
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-07-28T22:16:23.307Z
Comments.Text: @nbro If the rephrasing is not useful, then please close the question. If any edits make it on-topic, then please inform.
Comments.UserDisplayName: hanugm
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-07-30T12:53:42.020Z
Comments.Text: I think rephrasing is useful, but this still seems to be related to some specific thing about PyTorch. Maybe other libraries don't have these "buffers". I will leave it open for now.
Comments.UserDisplayName: nbro
Tags: <neural-networks><pytorch><weights>
Title: What are the numbers that are useful (may need to be stored) other than parameters of a model?
UserDisplayName: hanugm
ThreadText: # What are the numbers that are useful (may need to be stored) other than parameters of a model?
  
  (Asked by: username_0 on 2021-07-18)
  
  Consider the following method related to buffers in PyTorch
  buffers(recurse=True)
  
  Returns an iterator over module buffers.
  
  Parameters
  
      recurse (bool) – if True, then yields buffers of this module and all submodules. Otherwise, yields only buffers that are direct members of this module.
  
  Yields
  
      torch.Tensor – module buffer
  
  buffers() is a method used for models (say neural networks) in PyTorch. model.buffers() contains the tensors related to the model and you can see it from the example provided below.
  >>> for buf in model.buffers():
  >>>     print(type(buf), buf.size())
   (20L,)
   (20L, 1L, 5L, 5L)
  
  The following method informs that a model in PyTorch has both parameters and buffers. So, buffers cannot be the same as the parameters (say weights) of the model.
   cpu()
  
      Moves all model parameters and buffers to the CPU.
  
  I am not aware of any numbers to store for a model other than its parameters. So, I have no idea what buffers of a model in the PyTorch store. But, this implies that there are some other numbers related to a model that needs to be stored for efficiency or other purposes.
  Is it PyTorch specific? Else, what are those numbers, other than parameters, that need to be stored for a model?
  
  **Tags:** neural-networks, pytorch, weights
  > **Comments:**
  > **username_1**: This question seems to be about an API and not strictly related to AI, although you probably thought that a "buffer" was something special in AI (but I don't think it is, i.e. a buffer is just some data structure that holds something in PyTorch: see [this discussion](https://discuss.pytorch.org/t/what-pytorch-means-by-buffers/120266)), so I think it's off-topic. So, if you also think this is a programming question, I will close it as off-topic. Feel free to provide an answer to this question before I close it, if you think this post could be useful in the future.  
  > **username_0**: @nbro The question is not about buffer. The question is about what do buffer store.Buffer is a tensor and stores numbers related to a neural network. I am asking about those numbers and their nature.  
  > **username_1**: I think this is still a programming question, as you're asking about the API and how it works. In PyTorch, apparently, these buffers can store some statistics (according to the link above), but this is not strictly related to AI.  
  > **username_0**: If I ask **Are there any numbers to store other than parameters of a model?** then will it be okay? @nbro  
  > **username_0**: @nbro If the rephrasing is not useful, then please close the question. If any edits make it on-topic, then please inform.  
  > **username_1**: I think rephrasing is useful, but this still seems to be related to some specific thing about PyTorch. Maybe other libraries don't have these "buffers". I will leave it open for now.  
  
  ---
  
  ## 0 answers
  
  