HolyBayes / pytorch_ard

Pytorch implementation of Variational Dropout Sparsifies Deep Neural Networks
MIT License
83 stars 16 forks source link

Cannot create LinearARD with bias=False #8

Closed ideafang closed 2 years ago

ideafang commented 2 years ago

The code got TypeError when I run the examples/boston_ard.py with no bias LinearARD layers.

I changed the LinearARD in DenseModelARD to no bias:

self.l1 = nn_ard.LinearARD(input_shape, hidden_size, bias=False)
self.l2 = nn_ard.LinearARD(hidden_size, output_shape, bias=False)

then, examples/boston_ard.py is failed with TypeError: unsupported operand type(s) for +=: 'Tensor' and 'NoneType

It may be necessary to determine whether bias=False in the line 36 and 39 of torch_ard.py

output += self.bias
...
output = F.linear(input, W) + self.bias
HolyBayes commented 2 years ago

Thank you! Fixed