添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

RuntimeError: Given groups=1, weight of size [16, 1, 3, 3, 3], expected input[250, 64, 4, 4, 4] to have 1 channels, but got 64 channels instead

Ask Question # Four 3D convolutional layers self.conv1 = nn.Conv3d(1,16, 3, stride=1, padding=1) self.pool1 = nn.MaxPool3d(kernel_size=(2,2,2), stride = (2,2,2)) self.conv2 = nn.Conv3d(16, 32, 3, stride=1, padding=1) self.pool2 = nn.MaxPool3d(kernel_size=(2,2,2), stride = (2,2,2)) self.conv3 = nn.Conv3d(32, 64, 3, stride=1, padding=1) self.conv3_drop = nn.Dropout(dropout_prob) self.pool3 = nn.MaxPool3d(kernel_size=(2,2,2), stride = (2,2,2)) self.conv4 = nn.Conv3d(64, 64, 3, stride=1, padding=1) self.conv4_drop = nn.Dropout(dropout_prob) # Five fully connected layers self.fc1 = nn.Linear(4096, 1500) self.fc1_drop = nn.Dropout(dropout_prob) self.fc2 = nn.Linear(1500, 500) self.fc2_drop = nn.Dropout(dropout_prob) self.fc3 = nn.Linear(500, 100) self.fc3_drop = nn.Dropout(dropout_prob) self.fc4 = nn.Linear(100, 50) self.fc4_drop = nn.Dropout(dropout_prob) self.fc5 = nn.Linear(50, 3) def forward(self, x): ## feedforward behavior of NBV-net x = self.pool1(F.relu(self.conv1(x))) x = self.pool2(F.relu(self.conv2(x))) x = self.pool3(F.relu(self.conv3(x))) x = self(F.relu(self.conv4(x))) # Aplanar x = x.view(x.size(0), -1) x = F.relu(self.fc1(x)) x = self.fc1_drop(x) x = F.relu(self.fc2(x)) x = self.fc2_drop(x) x = F.relu(self.fc3(x)) x = self.fc3_drop(x) x = F.relu(self.fc4(x)) x = self.fc4_drop(x) x = F.tanh(self.fc5(x)) return x

RuntimeError: Given groups=1, weight of size [16, 1, 3, 3, 3], expected input[250, 64, 4, 4, 4] to have 1 channels, but got 64 channels instead

But this code gives the Runtime Error. Similar errors are there but I could not understand what Group 1 and other dimensions mentioned exactly mean , any idea about the background of this error ?

The input shape for nn.Conv3d(1,16, 3, stride=1, padding=1) is (batch, channels, depth, height, width) .

You define that the channel size is 1 but your input tensor has 64 channels.

self.conv1 = nn.Conv3d(64,16, 3, stride=1, padding=1) will resolve you error

I got this error when changed the channel size to 16. RuntimeError: Given groups=1, weight of size [16, 64, 3, 3, 3], expected input[250, 1, 32, 32, 32] to have 64 channels, but got 1 channels instead abinaya jeyakrishnan Oct 28, 2022 at 8:18 your input tensor to a conv3d should have the following shape (batch, channels, depth, height, width) Alexander Riedel Nov 1, 2022 at 8:32

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question . Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers .