DehazeNet_Pytorch icon indicating copy to clipboard operation
DehazeNet_Pytorch copied to clipboard

AttributeError: module 'torch.nn' has no attribute 'BReLU'

Open ckxin opened this issue 4 years ago • 7 comments

When I run the train() function, I get this error. There is a comment in the file DehazeNet-pytorch.py:

BRelu used for GPU. Need to add that reference in pytorch source file.

I don't quite understand what it means, whether it caused the problem? Please help, I would be grateful.

ckxin avatar Jul 06 '20 13:07 ckxin

torch.nn里没有BReLU这个激活函数,要把作者自己写的BReLU添加到PyTorch源文件里

XinzheGeng avatar Nov 06 '20 10:11 XinzheGeng

你好 如果是自己实验的话 可以修改源文件,在ReLU的源文件里自己写一个,仿照ReLU来写,开头加上BReLU的引用 或者你可以直接换一个激活函数

发自我的iPhone

------------------ Original ------------------ From: Scotty1027 <[email protected]> Date: Fri,Nov 6,2020 6:45 PM To: thuBingo/DehazeNet_Pytorch <[email protected]> Cc: Subscribed <[email protected]> Subject: Re: [thuBingo/DehazeNet_Pytorch] AttributeError: module 'torch.nn' has no attribute 'BReLU' (#1)

torch.nn里没有BReLU这个激活函数

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

thuBingo avatar Nov 11 '20 08:11 thuBingo

@Scotty1027 `@weak_module class BReLU(Hardtanh): def init(self, inplace=False): super(BReLU, self).init(0., 1., inplace)

def extra_repr(self):
    inplace_str = 'inplace=True' if self.inplace else ''
    return inplace_str`

我在activation.py中修改了源码,可是依然报错,请问是什么原因?

rjx678 avatar Nov 28 '20 07:11 rjx678

@Scotty1027 `@weak_module class BReLU(Hardtanh): def init(self, inplace=False): super(BReLU, self).init(0., 1., inplace)

def extra_repr(self):
    inplace_str = 'inplace=True' if self.inplace else ''
    return inplace_str`

我在activation.py中修改了源码,可是依然报错,请问是什么原因?

你可以发一下你的报错内容; 或者直接调用原作者定义的BReLU(),不去修改activation.py image

XinzheGeng avatar Nov 29 '20 07:11 XinzheGeng

你好,想咨询一下怎么在pytorch 源文件中修改?或者说具体是哪个代码文件中修改呢?总感觉现在的代码不是很完整,少了一些东西。

sun0912704 avatar Mar 30 '22 07:03 sun0912704

我没有修改pytorch的源文件,而是直接调用了作者写的BReLU()到网络中,具体如图 1648625571(1)

XinzheGeng avatar Mar 30 '22 07:03 XinzheGeng

@XinzheGeng 请问有没有发现测试图像都偏黑,准确说是特别黑

djdll avatar Mar 25 '24 13:03 djdll