<p>The <code>3</code> is the number of input channels (<code>R</code>, <code>G</code>, <code>B</code>). That <code>64</code> is the number of channels (i.e. <em>feature maps</em>) in the output of the first convolution operation. So, the first conv layer takes a color (RGB) image as input, applies <code>11x11</code> kernel with a stride 4, and outputs <code>64</code> feature maps.</p>

<p>I agree that this is different from the number of channels (<code>96</code>, 48 in each GPU) in the architecture diagram (of original AlexNet implementation).</p>

<p>However, PyTorch does not implement the original Alexnet architecture. Rather it implements a variant of the AlexNet implementation described in the paper: <a href="https://arxiv.org/abs/1404.5997" rel="nofollow noreferrer"><code>One weird trick for parallelizing convolutional neural networks</code></a>.</p>

<p>Also, see <a href="http://cs231n.github.io/convolutional-networks/#conv" rel="nofollow noreferrer">cs231n - convolutional networks</a> for more details about how input, filters, stride, and padding equates to output after the conv operation.</p>

<hr>

<p>P.S: See <a href="https://github.com/pytorch/vision/issues/185" rel="nofollow noreferrer"><code>pytorch/vision/issues/185</code></a></p>
How to get the input and output channels in a CNN?
<p>I am specifically looking at the AlexNet architecture found here:
<a href="https://github.com/pytorch/vision/blob/master/torchvision/models/alexnet.py" rel="nofollow noreferrer">https://github.com/pytorch/vision/blob/master/torchvision/models/alexnet.py</a></p>
<p>I am confused as to how they are getting the input and output channels. Based on my readings of the AlexNet, I can't figure out where they are getting <em>outputchannels = 64</em> from (as the second argument to the <code>Conv2d</code> function). Even if the <em>256</em> is split across 2 GPUs, that should give <em>128</em> rather than <em>64</em>. The input channel of 3 initially represents the color channels as per my assumption. However, the other input and output channels don't make sense to me either.</p>
<p>Could anyone clarify what the input and output channels are?</p>
<pre><code>class AlexNet(nn.Module):

    def __init__(self, num_classes=1000):
        super(AlexNet, self).__init__()
        self.features = nn.Sequential(
            nn.Conv2d(3, 64, kernel_size=11, stride=4, padding=2), #why 64?
            nn.ReLU(inplace=True),
            nn.MaxPool2d(kernel_size=3, stride=2),
            nn.Conv2d(64, 192, kernel_size=5, padding=2),
            nn.ReLU(inplace=True),
            nn.MaxPool2d(kernel_size=3, stride=2),
            nn.Conv2d(192, 384, kernel_size=3, padding=1),
            nn.ReLU(inplace=True),
            nn.Conv2d(384, 256, kernel_size=3, padding=1),
            nn.ReLU(inplace=True),
            nn.Conv2d(256, 256, kernel_size=3, padding=1),
            nn.ReLU(inplace=True),
            nn.MaxPool2d(kernel_size=3, stride=2),
        )
</code></pre>
<p><a href="https://i.stack.imgur.com/rPOTl.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rPOTl.jpg" alt="enter image description here" /></a></p>