question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Modify YOLOv3 backbone from DarkNet to AdderNet

See original GitHub issue

How to correctly modify https://github.com/eriklindernoren/PyTorch-YOLOv3 to use https://github.com/huawei-noah/AdderNet ?

The following colab ipynb notebook is what I have so far with the helps of others:

https://colab.research.google.com/drive/1VCafwykgNKAO6144LssBFFy0TmruDNSE#scrollTo=W3e-WcVxnKfs

How to solve the error on this models.py file ?

addernet_error

Namespace(batch_size=8, class_path='data/coco.names', conf_thres=0.001, data_config='config/coco.data', img_size=416, iou_thres=0.5, model_def='config/yolov3.cfg', n_cpu=8, nms_thres=0.5, weights_path='weights/yolov3.weights')
Traceback (most recent call last):
  File "test.py", line 84, in <module>
    model.load_darknet_weights(opt.weights_path)
  File "/content/PyTorch-YOLOv3/models.py", line 321, in load_darknet_weights
    num_w = conv_layer.weight.numel()
  File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py", line 576, in __getattr__
    type(self).__name__, name))
AttributeError: 'adder2d' object has no attribute 'weight'

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:20

github_iconTop GitHub Comments

2reactions
HantingChencommented, Apr 11, 2020

‘adder2d’ object has no attribute ‘weight’, you may change the definition of self.adder with self.weight in class adder2d.

1reaction
buttercuttercommented, Apr 18, 2020

@summeryumyee

For your question in https://github.com/eriklindernoren/PyTorch-YOLOv3/issues/482#issuecomment-615583101, you could use modification in the following class :

class adder2d(nn.Module):

    def __init__(self,input_channel,output_channel,kernel_size, stride=1, padding=0, bias = False):
        super(adder2d, self).__init__()
        self.stride = stride
        self.padding = padding
        self.input_channel = input_channel
        self.output_channel = output_channel
        self.kernel_size = kernel_size
        self.adder = torch.nn.Parameter(nn.init.normal_(torch.randn(output_channel,input_channel,kernel_size,kernel_size)))
        self.bias = bias
        if bias:
            self.b = torch.nn.Parameter(nn.init.uniform_(torch.zeros(output_channel)))

    def forward(self, x):
        output = adder2d_function(x,self.adder, self.stride, self.padding)
        if self.bias:
            output += self.b.unsqueeze(0).unsqueeze(2).unsqueeze(3)
        
        return output
Read more comments on GitHub >

github_iconTop Results From Across the Web

Modify YOLOv3 backbone from DarkNet to AdderNet #482
@dabblle I am asking about reducing GPU memory usage, not CPU resource usage. Or did I miss anything ? All reactions.
Read more >
Modify YOLOv3 backbone from DarkNet to AdderNet
How to solve the error on this models.py file ? However, I am still stuck at how the image dataloader works.
Read more >
Modify YOLOv3 backbone from DarkNet to AdderNet : r/pytorch
I have solved the epoch 0 issue by using the advice given at huawei-noah/AdderNet#16 (comment). See the latest ipynb file.
Read more >
Replacing YoloV3 Backbone with ChexNet for Pneumonia ...
We passed a parameter backbone with values darknet and chexnet to keep it modular and to change the YoloV3 backbone accordingly. To get...
Read more >
Darknet-53 Explained | Papers With Code
Darknet -53 is a convolutional neural network that acts as a backbone for the ... Introduced by Redmon et al. in YOLOv3: An...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found