title: Pytorch and batches
body: <p>I'm having trouble understanding how batches play a role into the Pytorch framework.</p>
  <p>In this model:</p>
  <pre><code>class MyModel(nn.Module):
      def __init__(self):
          super(MyModel, self).__init__()
  
          # 28x28x1 =&gt; 26x26x32
          self.conv1 = nn.Conv2d(in_channels=1, out_channels=32, kernel_size=3)
          self.d1 = nn.Linear(26 * 26 * 32, 128)
          self.d2 = nn.Linear(128, 10)
  
      def forward(self, x):
          # 32x1x28x28 =&gt; 32x32x26x26
          x = self.conv1(x)
          x = F.relu(x)
  
          # flatten =&gt; 32 x (32*26*26)
          x = x.flatten(start_dim = 1)
          #x = x.view(32, -1)
  
          # 32 x (32*26*26) =&gt; 32x128
          x = self.d1(x)
          x = F.relu(x)
  
          # logits =&gt; 32x10
          logits = self.d2(x)
          out = F.softmax(logits, dim=1)
          return out
  </code></pre>
  <p>In the forward definition, we pass in some <code>x</code>, ie. aggregated images for a batch from a DataLoader. Here, the <code>32x1x28x28</code> dimension indicates that there are 32 images in a batch. Do we just ignore this fact and Pytorch handles applying Conv2d to each sample? The forward propagation seems to be just relative to a single image.</p>