How to keep depth the same across conv3d layer

drydenwiebe: <p>Hello,</p>
<p>I am trying to use a conv3d layer to for images with multiple frames, but I would like the output to have the same depth before and after the layer (ie: D == D_out like <a href="https://pytorch.org/docs/stable/generated/torch.nn.Conv3d.html" rel="noopener nofollow ugc">this</a>.</p>
<p>Right now my input shape is:</p>
<p>(6, 5, 3, 78, 136)</p>
<p>This is with a batch size of 6, and a depth of 5 (ie: D = 5)</p>
<p>The conv3d block is initialized as:</p>
<p>torch.nn.Conv3d(3, 64, kernel_size=3, padding=1, stride=(1, 2, 2))</p>
<p>When I run this, the error I get is:</p>
<p>RuntimeError: Given groups=1, weight of size [64, 2, 3, 3, 3], expected input[6, 5, 2, 78, 136] to have 2 channels, but got 5 channels instead</p>
<p>I guess what I want is weights of size [64, 5, 3, 3, 3] to have D = D_out. How can I accomplish this?</p>

drydenwiebe: <p>According to the formula for D_out <a href="https://pytorch.org/docs/stable/generated/torch.nn.Conv3d.html" rel="noopener nofollow ugc">here</a></p>
<p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/f/7/f7c567455dfe649985b81eed214d8d6269aee73b.png" data-download-href="https://discuss.pytorch.org/uploads/default/f7c567455dfe649985b81eed214d8d6269aee73b" title="image"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/f/7/f7c567455dfe649985b81eed214d8d6269aee73b_2_690x55.png" alt="image" data-base62-sha1="zlSRWqNnibBWyPrGlNHzIPW1SDV" width="690" height="55" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/f/7/f7c567455dfe649985b81eed214d8d6269aee73b_2_690x55.png, https://discuss.pytorch.org/uploads/default/optimized/3X/f/7/f7c567455dfe649985b81eed214d8d6269aee73b_2_1035x82.png 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/f/7/f7c567455dfe649985b81eed214d8d6269aee73b_2_1380x110.png 2x" data-dominant-color="000000"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">2438×196 14.7 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>
<p>For this case this is:</p>
<p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/4/0/40bb6ce7df23e76ea8b0763ec874d590726ad97c.png" data-download-href="https://discuss.pytorch.org/uploads/default/40bb6ce7df23e76ea8b0763ec874d590726ad97c" title="image"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/4/0/40bb6ce7df23e76ea8b0763ec874d590726ad97c_2_690x76.png" alt="image" data-base62-sha1="9eE78QpudsyM5f9iUZKpjemVIvO" width="690" height="76" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/4/0/40bb6ce7df23e76ea8b0763ec874d590726ad97c_2_690x76.png, https://discuss.pytorch.org/uploads/default/optimized/3X/4/0/40bb6ce7df23e76ea8b0763ec874d590726ad97c_2_1035x114.png 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/4/0/40bb6ce7df23e76ea8b0763ec874d590726ad97c_2_1380x152.png 2x" data-dominant-color="000000"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">1582×176 7.38 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>
<p>Which should be 5, as expected so I am not sure what is happening.</p>

drydenwiebe: <p>Figured it out. My channels and depth were swapped for my input tensor.</p>