title: Pytorch Architecture Failure
body: <p>I am trying to build my own resent architecture.
  I have the following Resent Architecture:</p>
  <pre><code>ResNetClassifier(
    (feature_extractor): Sequential(
      (0): ResidualBlock(
        (main_path): Sequential(
          (0): Conv2d(3, 32, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
          (1): Dropout2d(p=0.1, inplace=False)
          (2): BatchNorm2d(32, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
          (3): LeakyReLU(negative_slope=0.01)
          (4): Conv2d(32, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
          (5): Dropout2d(p=0.1, inplace=False)
          (6): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
          (7): LeakyReLU(negative_slope=0.01)
          (8): Conv2d(64, 32, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
          (9): Dropout2d(p=0.1, inplace=False)
          (10): BatchNorm2d(32, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
          (11): LeakyReLU(negative_slope=0.01)
          (12): Conv2d(32, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
          (13): Dropout2d(p=0.1, inplace=False)
          (14): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
          (15): LeakyReLU(negative_slope=0.01)
          (16): Conv2d(64, 32, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
          (17): Dropout2d(p=0.1, inplace=False)
          (18): BatchNorm2d(32, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
          (19): LeakyReLU(negative_slope=0.01)
          (20): Conv2d(32, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
        )
        (shortcut_path): Conv2d(3, 64, kernel_size=(1, 1), stride=(1, 1), bias=False)
      )
      (1): ResidualBlock(
        (main_path): Sequential(
          (0): Conv2d(3, 32, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
          (1): Dropout2d(p=0.1, inplace=False)
          (2): BatchNorm2d(32, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
          (3): LeakyReLU(negative_slope=0.01)
          (4): Conv2d(32, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
          (5): Dropout2d(p=0.1, inplace=False)
          (6): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
          (7): LeakyReLU(negative_slope=0.01)
          (8): Conv2d(64, 32, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
          (9): Dropout2d(p=0.1, inplace=False)
          (10): BatchNorm2d(32, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
          (11): LeakyReLU(negative_slope=0.01)
          (12): Conv2d(32, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
          (13): Dropout2d(p=0.1, inplace=False)
          (14): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
          (15): LeakyReLU(negative_slope=0.01)
          (16): Conv2d(64, 32, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
          (17): Dropout2d(p=0.1, inplace=False)
          (18): BatchNorm2d(32, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
          (19): LeakyReLU(negative_slope=0.01)
          (20): Conv2d(32, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
        )
        (shortcut_path): Conv2d(3, 64, kernel_size=(1, 1), stride=(1, 1), bias=False)
      )
      (2): ResidualBlock(
        (main_path): Sequential(
          (0): Conv2d(3, 32, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
          (1): Dropout2d(p=0.1, inplace=False)
          (2): BatchNorm2d(32, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
          (3): LeakyReLU(negative_slope=0.01)
          (4): Conv2d(32, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
          (5): Dropout2d(p=0.1, inplace=False)
          (6): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
          (7): LeakyReLU(negative_slope=0.01)
          (8): Conv2d(64, 32, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
          (9): Dropout2d(p=0.1, inplace=False)
          (10): BatchNorm2d(32, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
          (11): LeakyReLU(negative_slope=0.01)
          (12): Conv2d(32, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
          (13): Dropout2d(p=0.1, inplace=False)
          (14): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
          (15): LeakyReLU(negative_slope=0.01)
          (16): Conv2d(64, 32, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
          (17): Dropout2d(p=0.1, inplace=False)
          (18): BatchNorm2d(32, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
          (19): LeakyReLU(negative_slope=0.01)
          (20): Conv2d(32, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
        )
        (shortcut_path): Conv2d(3, 64, kernel_size=(1, 1), stride=(1, 1), bias=False)
      )
      (3): ResidualBlock(
        (main_path): Sequential(
          (0): Conv2d(3, 32, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
          (1): Dropout2d(p=0.1, inplace=False)
          (2): BatchNorm2d(32, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
          (3): LeakyReLU(negative_slope=0.01)
          (4): Conv2d(32, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
          (5): Dropout2d(p=0.1, inplace=False)
          (6): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
          (7): LeakyReLU(negative_slope=0.01)
          (8): Conv2d(64, 32, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
          (9): Dropout2d(p=0.1, inplace=False)
          (10): BatchNorm2d(32, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
          (11): LeakyReLU(negative_slope=0.01)
          (12): Conv2d(32, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
          (13): Dropout2d(p=0.1, inplace=False)
          (14): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
          (15): LeakyReLU(negative_slope=0.01)
          (16): Conv2d(64, 32, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
          (17): Dropout2d(p=0.1, inplace=False)
          (18): BatchNorm2d(32, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
          (19): LeakyReLU(negative_slope=0.01)
          (20): Conv2d(32, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
        )
        (shortcut_path): Conv2d(3, 64, kernel_size=(1, 1), stride=(1, 1), bias=False)
      )
      (4): AvgPool2d(kernel_size=2, stride=2, padding=0)
      (5): ResidualBlock(
        (main_path): Sequential(
          (0): Conv2d(32, 32, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
          (1): Dropout2d(p=0.1, inplace=False)
          (2): BatchNorm2d(32, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
          (3): LeakyReLU(negative_slope=0.01)
          (4): Conv2d(32, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
          (5): Dropout2d(p=0.1, inplace=False)
          (6): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
          (7): LeakyReLU(negative_slope=0.01)
          (8): Conv2d(64, 32, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
          (9): Dropout2d(p=0.1, inplace=False)
          (10): BatchNorm2d(32, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
          (11): LeakyReLU(negative_slope=0.01)
          (12): Conv2d(32, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
          (13): Dropout2d(p=0.1, inplace=False)
          (14): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
          (15): LeakyReLU(negative_slope=0.01)
          (16): Conv2d(64, 32, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
          (17): Dropout2d(p=0.1, inplace=False)
          (18): BatchNorm2d(32, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
          (19): LeakyReLU(negative_slope=0.01)
          (20): Conv2d(32, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
        )
        (shortcut_path): Conv2d(32, 64, kernel_size=(1, 1), stride=(1, 1), bias=False)
      )
      (6): ResidualBlock(
        (main_path): Sequential(
          (0): Conv2d(32, 32, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
          (1): Dropout2d(p=0.1, inplace=False)
          (2): BatchNorm2d(32, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
          (3): LeakyReLU(negative_slope=0.01)
          (4): Conv2d(32, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
          (5): Dropout2d(p=0.1, inplace=False)
          (6): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
          (7): LeakyReLU(negative_slope=0.01)
          (8): Conv2d(64, 32, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
          (9): Dropout2d(p=0.1, inplace=False)
          (10): BatchNorm2d(32, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
          (11): LeakyReLU(negative_slope=0.01)
          (12): Conv2d(32, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
          (13): Dropout2d(p=0.1, inplace=False)
          (14): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
          (15): LeakyReLU(negative_slope=0.01)
          (16): Conv2d(64, 32, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
          (17): Dropout2d(p=0.1, inplace=False)
          (18): BatchNorm2d(32, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
          (19): LeakyReLU(negative_slope=0.01)
          (20): Conv2d(32, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
        )
        (shortcut_path): Conv2d(32, 64, kernel_size=(1, 1), stride=(1, 1), bias=False)
      )
    )
    (classifier): Sequential(
      (0): Linear(in_features=518400, out_features=100, bias=True)
      (1): LeakyReLU(negative_slope=0.01)
      (2): Linear(in_features=100, out_features=100, bias=True)
      (3): LeakyReLU(negative_slope=0.01)
      (4): Linear(in_features=100, out_features=10, bias=True)
    )
  )
  </code></pre>
  <p>when sending tensor in size torch.Size([1, 3, 100, 100])
  with the following code</p>
  <pre><code>net = cnn.ResNetClassifier(
      in_size=(3,100,100), out_classes=10, channels=[32, 64]*3,
      pool_every=4, hidden_dims=[100]*2,
      activation_type='lrelu', activation_params=dict(negative_slope=0.01),
      pooling_type='avg', pooling_params=dict(kernel_size=2),
      batchnorm=True, dropout=0.1,
  )
  print(net)
  
  torch.manual_seed(seed)
  
  test_image = torch.randint(low=0, high=256, size=(3, 100, 100), dtype=torch.float).unsqueeze(0)
  test_out = net(test_image)
  print('out =', test_out)
  </code></pre>
  <p>it fails with following error:</p>
  <p>&quot;RuntimeError: Given groups=1, weight of size [32, 3, 3, 3], expected input[1, 64, 100, 100] to have 3 channels, but got 64 channels instead&quot;</p>
  <p>Any clue to solve it will be appreciated!</p>
  <p>BTW, what is the recommended way to debug such network errors?</p>