Hey Pytorch-Masters,
I want to feed more than one picture in one ConvBlock, so you can see it as one more than one shortcut in a Resnet. But I got an Exception like :
if in_channels % groups != 0:
RuntimeError: Boolean value of Tensor with more than one value is ambiguous
Thats my Block I am testing:
class three_ConvBlock(nn.Module):
def __init__(self, in_ch, out_ch, conv_index, customized_shortcut):
super(three_ConvBlock, self).__init__()
conv_index = nn.Parameter(conv_index)
customized_shortcut = nn.Parameter(customized_shortcut)
self.layer_1 = nn.Conv3d(in_ch,out_ch,3,stride=(1,1,1), padding=0)
self.layer_2 = nn.Conv3d(in_ch,out_ch,3, stride=(1,1,1), padding=0)
def forward(self,x, conv_index, customized_shortcut):
x_1 = self.layer_1(x)
conv_index_out = x_1
x_2 = torch.sub(x_1,customized_shortcut)
x_2 = torch.cat((x_2,conv_index))
x_3 = self.layer_2(x_1)
#print(conv_index, customized_shortcut)
return x_3 , conv_index_out
Image = torch.randint(10, (3,3,3),requires_grad=True,dtype=torch.float64)
a = torch.randint(5, (3,3,3),requires_grad=True,dtype=torch.float64)
b = torch.randint(4, (3,3,3),requires_grad=True,dtype=torch.float64)
test_layer = three_ConvBlock(Image,Image,conv_index=a,customized_shortcut=b)
result = test_layer(Image,conv_index=a,customized_shortcut=b)
#print(model.parameters)
print(result)
Thanks for any advice!!!