Hi, I’m currently using Blitz to create a 3D bayesian Unet and when trying to train the model I get the following error:
Input type (torch.cuda.FloatTensor) and bias type (torch.FloatTensor) should be the same
I have searched around similar topics, I found one for the same error which didn’t help, and several regarding a similar message but about the weights, which was also of no help for this situation (both model and data are going for the same cuda device).
The model is defined here: model - Pastebin.com 1
And the training loop is here: loop - Pastebin.com
The definition of the BayesianConv3d layer can be found here.
Full error trace below.
Any help regarding this would be greatly appreciated.
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-12-d8ddbcf20a6e> in <module>
     19         #print("labels: ", labels.shape)
     20         optimizer.zero_grad()
---> 21         outputs = model(inputs)
     22         #loss = loss_function(outputs, labels)
     23         loss = model.sample_elbo(inputs=inputs,

~/miniconda3/lib/python3.8/site-packages/torch/nn/modules/module.py in _call_impl(self, *input, **kwargs)
    887             result = self._slow_forward(*input, **kwargs)
    888         else:
--> 889             result = self.forward(*input, **kwargs)
    890         for hook in itertools.chain(
    891                 _global_forward_hooks.values(),

~/Desktop/bayesian/BUNet3D.py in forward(self, x)
    115 
    116     def forward(self, x):
--> 117         x1 = self.convd1(x)
    118         x2 = self.convd2(x1)
    119         x3 = self.convd3(x2)

~/miniconda3/lib/python3.8/site-packages/torch/nn/modules/module.py in _call_impl(self, *input, **kwargs)
    887             result = self._slow_forward(*input, **kwargs)
    888         else:
--> 889             result = self.forward(*input, **kwargs)
    890         for hook in itertools.chain(
    891                 _global_forward_hooks.values(),

~/Desktop/bayesian/BUNet3D.py in forward(self, x)
     42         if not self.first:
     43             x = self.maxpool(x)
---> 44         x = self.conv1(x)
     45         x = self.bn1(x)
     46         #x = self.bn1(self.conv1(x))

~/miniconda3/lib/python3.8/site-packages/torch/nn/modules/module.py in _call_impl(self, *input, **kwargs)
    887             result = self._slow_forward(*input, **kwargs)
    888         else:
--> 889             result = self.forward(*input, **kwargs)
    890         for hook in itertools.chain(
    891                 _global_forward_hooks.values(),

~/miniconda3/lib/python3.8/site-packages/blitz/modules/conv_bayesian_layer.py in forward(self, x)
    366         self.log_prior = self.weight_prior_dist.log_prior(w) + b_log_prior
    367 
--> 368         return F.conv3d(input=x,
    369                         weight=w,
    370                         bias=b,

RuntimeError: Input type (torch.cuda.FloatTensor) and bias type (torch.FloatTensor) should be the same