Non-local_pytorch icon indicating copy to clipboard operation
Non-local_pytorch copied to clipboard

AttributeError: 'NoneType' object has no attribute 'fill_'

Open Mr-doraemon opened this issue 3 years ago • 1 comments

I want to embed this non-local code in my framework, but when I run my code, the following error will occur:

File "/home/Global/models/non_local_embeded_gaussian.py", line 102, in init super(NONLocalBlock2D, self).init(in_channels, File "/home/Global/models/non_local_embeded_gaussian.py", line 54, in init nn.init.constant_(self.W[1].weight, 0) File "/home/anaconda3/envs/torch/lib/python3.8/site-packages/torch/nn/init.py", line 176, in constant_ return no_grad_fill(tensor, val) File "/home/anaconda3/envs/torch/lib/python3.8/site-packages/torch/nn/init.py", line 59, in no_grad_fill return tensor.fill_(val) AttributeError: 'NoneType' object has no attribute 'fill_'

In my envirnoment, the pyhton version: 3.8, torch version: 1.8.0, cuda:11.2

Mr-doraemon avatar Aug 16 '21 09:08 Mr-doraemon

@Mr-doraemon Hi, it seems that self.W[1].weight is None.

AlexHex7 avatar Aug 30 '21 05:08 AlexHex7