tengshaofeng / ResidualAttentionNetwork-pytorch

a pytorch code about Residual Attention Network. This code is based on two projects from
675 stars 164 forks source link

It seems that the this code reproduced results can not achieve the results in the original paper ? #1

Open YihangLou opened 6 years ago

Hiiamein commented 5 years ago

I run the code by python train.py. Then I got the following errors. Do you know how to fix it?

model = ResidualAttentionModel().cuda()
  File "/cluster/home/it_stu19/ResidualAttentionNetwork-pytorch/Residual-Attention-Network/model/residual_attention_network.py", line 236, in __init__
    self.residual_block1 = ResidualBlock(32, 128)  # 32*32
  File "/cluster/home/it_stu19/ResidualAttentionNetwork-pytorch/Residual-Attention-Network/model/basic_layers.py", line 16, in __init__
    self.conv1 = nn.Conv2d(input_channels, output_channels/4, 1, 1, bias = False)
  File "/cluster/apps/anaconda3/5.3.0/lib/python3.6/site-packages/torch/nn/modules/conv.py", line 315, in __init__
    False, _pair(0), groups, bias)
  File "/cluster/apps/anaconda3/5.3.0/lib/python3.6/site-packages/torch/nn/modules/conv.py", line 38, in __init__
    out_channels, in_channels // groups, *kernel_size))
TypeError: new() received an invalid combination of arguments - got (float, int, int, int), but expected one of:
 * (torch.device device)
 * (torch.Storage storage)
 * (Tensor other)
 * (tuple of ints size, torch.device device)
 * (object data, torch.device device)
skyguidance commented 5 years ago

@ArtechStark It looks like you are using Python 3. The divide function in Python 3 is different in Python 2, which causes float result in nn.conv2D input. Change ResidualBlock output_layer calculation in basic_layers.py will solve this problem.

Hiiamein commented 5 years ago

@skyguidance Thank you very much! The problem is solved now.

gden138 commented 5 years ago

@tengshaofeng https://arxiv.org/pdf/1812.01187.pdf

谢谢你们的帮助 我自己改进后也达到97%

请问您如何改进的,能不能说一下细节,非常感谢。

November666 commented 4 years ago

excuse me,your code bring me a big help about my research,but,when i run the train.py,it appears the following errors,do you konw how to fix it? thank you! RuntimeError: An attempt has been made to start a new process before the current process has finished its bootstrapping phase.

    This probably means that you are not using fork to start your
    child processes and you have forgotten to use the proper idiom
    in the main module:

        if __name__ == '__main__':
            freeze_support()
            ...

    The "freeze_support()" line can be omitted if the program
    is not going to be frozen to produce an executable.

ForkingPickler(file, protocol).dump(obj)

BrokenPipeError: [Errno 32] Broken pipe

tengshaofeng commented 4 years ago

Install the torch compiled with cuda,if gpu is available

发自我的iPhone

------------------ Original ------------------ From: November666 <notifications@github.com> Date: Wed,Oct 23,2019 6:41 PM To: tengshaofeng/ResidualAttentionNetwork-pytorch <ResidualAttentionNetwork-pytorch@noreply.github.com> Cc: bojohn <307149416@qq.com>, Mention <mention@noreply.github.com> Subject: Re: [tengshaofeng/ResidualAttentionNetwork-pytorch] It seems that the this code reproduced results can not achieve the results in the original paper ? (#1)

excuse me,your code bring me a big help about my research,but,when i run the train.py,it appears the following errors,do you konw how to fix it? thank you! Traceback (most recent call last): File "D:/wcj/code/python/ClassicNetwork-master/demo15.py", line 104, in model=ft_net().cuda() File "C:\Users\cg\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 311, in cuda return self._apply(lambda t: t.cuda(device)) File "C:\Users\cg\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 208, in _apply module._apply(fn) File "C:\Users\cg\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 208, in _apply module._apply(fn) File "C:\Users\cg\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 230, in _apply param_applied = fn(param) File "C:\Users\cg\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 311, in return self.apply(lambda t: t.cuda(device)) File "C:\Users\cg\Anaconda3\lib\site-packages\torch\cuda_init.py", line 178, in _lazy_init check_driver() File "C:\Users\cg\Anaconda3\lib\site-packages\torch\cuda_init.py", line 92, in _check_driver raise AssertionError("Torch not compiled with CUDA enabled") AssertionError: Torch not compiled with CUDA enabled

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