Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

precision #1

Open
swjtulinxi opened this issue Jan 10, 2020 · 13 comments
Open

precision #1

swjtulinxi opened this issue Jan 10, 2020 · 13 comments

Comments

@swjtulinxi
Copy link

have you compared the moiu between your cc.py and the original code on cityscapes ???
becauese i have test your cc.py,and .....

@Serge-weihao
Copy link
Owner

have you compared the moiu between your cc.py and the original code on cityscapes ???
becauese i have test your cc.py,and .....

I have checked the mIoUs, but I dont know what is the measure of moiu.

@swjtulinxi
Copy link
Author

swjtulinxi commented Jan 10, 2020 via email

@Serge-weihao
Copy link
Owner

can the miou reach 80%------------------ 原始邮件 ------------------

I load the same checkpoint using our pure PyTorch implementation and the official cc_attention, the mIoU results are almost the same, because the calculation is the same. If you have a ckpt with a testing code of 80% of the original cc_attention, my implementation can get the same results.

@Serge-weihao
Copy link
Owner

Serge-weihao commented Jan 10, 2020

The same CKPT of 30000/60000, using official inplace-abn
Testing with

  1. official CUDA cc_attention
    图片
  2. My CC.py
    图片

@swjtulinxi
Copy link
Author

i see ,thank you for yor code,beacuse i can not use the original code, your code can work on my computer,i don't know why.

@swjtulinxi
Copy link
Author

the original code is not like yours,i don't understand his code ,for example , _ext. is for what, i can't understand

def _check_contiguous(*args):
if not all([mod is None or mod.is_contiguous() for mod in args]):
raise ValueError("Non-contiguous input")

class CA_Weight(autograd.Function):
@staticmethod
def forward(ctx, t, f):
# Save context
n, c, h, w = t.size()
size = (n, h+w-1, h, w)
weight = torch.zeros(size, dtype=t.dtype, layout=t.layout, device=t.device)

    **_ext**.ca_forward_cuda(t, f, weight)
    
    # Output
    ctx.save_for_backward(t, f)

    return weight

@staticmethod
@once_differentiable
def backward(ctx, dw):
    t, f = ctx.saved_tensors

    dt = torch.zeros_like(t)
    df = torch.zeros_like(f)

    _ext.ca_backward_cuda(dw.contiguous(), t, f, dt, df)

    _check_contiguous(dt, df)

    return dt, df

@Serge-weihao
Copy link
Owner

the original code is not like yours,i don't understand his code ,for example , _ext. is for what, i can't understand

They use CPP extension with CUDA, so you may have some problems of compatibility(兼容性). The official inplace-abn is also a CUDA implementation.

@Serge-weihao
Copy link
Owner

What op sys are you using, Linux or Win?

@swjtulinxi
Copy link
Author

win

@Serge-weihao
Copy link
Owner

This repo uses Synchronized-BatchNorm-PyTorch as cross gpus BatchNorm, it costs more gpu memory. I have tested it for batchsize of 4, the result is about 67, so I think the Synchronized-BatchNorm-PyTorch may have some problems or the training hyperparameters are not good for batchsize of 4. I use inplace-abn under Linux, and I will implement inplace-abn using pure PyTorch in the future.

@swjtulinxi
Copy link
Author

i just one GPU,so i use the nn.batchnorm2d,

@swjtulinxi
Copy link
Author

the paper said ,the batchsize shoud be 12 or higer when we training ,otherwise it will affect the result

@Serge-weihao
Copy link
Owner

inplace-abn can save some GPU memory for training, but the official CUDA inplace-abn may not support Windows well. If this repo is helpful for you, you can star it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants