title: RuntimeError: Given groups=1, weight of size [32, 3, 3, 3], expected input[4, 32, 6, 7] to have 3 channels, but got 32 channels instead
body: <p>I am trying to implement such CNN.</p>
  <p><a href="https://i.stack.imgur.com/XHB8r.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XHB8r.png" alt="enter image description here" /></a></p>
  <p>This is my implementation:</p>
  <pre><code>class Net(BaseFeaturesExtractor):
      def __init__(self, observation_space: gym.spaces.Box, features_dim: int = 256):
          super(Net, self).__init__(observation_space, features_dim)
          n_input_channels = observation_space.shape[0]
          print(&quot;Observation space shape:&quot;+str(observation_space.shape))
          print(&quot;Number of channels:&quot; + str(n_input_channels))
          self.cnn = nn.Sequential(
              nn.Conv2d(n_input_channels, 32, kernel_size=3, stride=1, padding=1),
              nn.ReLU(),
              nn.Conv2d(n_input_channels, 32, kernel_size=3, stride=2, padding=1),
              nn.ReLU(),
              nn.Conv2d(n_input_channels, 32, kernel_size=3, stride=2, padding=1),
              nn.ReLU(),
              nn.Flatten(),
              nn.Linear(in_features=128,out_features=64),
              nn.ReLU(),
              nn.Linear(in_features=64,out_features=7),
              nn.Sigmoid()
          )
  
      def forward(self, observations: th.Tensor) -&gt; th.Tensor:
          print(&quot;Observation shape:&quot;+str(observations[0].shape))
          return self.cnn(observations)
  </code></pre>
  <p>When I tried to run the code which uses this CNN, I am getting following log:</p>
  <pre><code>    Observation space shape:(3, 6, 7) 
      Number of channels:3 
      Observation shape:torch.Size([3, 6, 7]) 
      Traceback (most recent call last):   File &quot;/Users/joe/Documents/JUPYTER/ConnectX/training3.py&quot;, line 250, in &lt;module&gt;
          learner.learn(total_timesteps=iterations, callback=eval_callback)
  ...
  RuntimeError: Given groups=1, weight of size [32, 3, 3, 3], expected input[4, 32, 6, 7] to have 3 channels, but got 32 channels instead
  </code></pre>
  <p>What is the problem here? How can I solve it?</p>