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

model.eval() seems not work well #35

Closed
mapleneverfade opened this issue Apr 9, 2018 · 11 comments · Fixed by #51
Closed

model.eval() seems not work well #35

mapleneverfade opened this issue Apr 9, 2018 · 11 comments · Fixed by #51

Comments

@mapleneverfade
Copy link

mapleneverfade commented Apr 9, 2018

It's very kind of your work ! There's still something i want for your help!
My code for model and criterion parallel like this:
model = encoding.parallel.ModelDataParallel(model,device_ids=[0,1,2])
criterion = encoding.parallel.CriterionDataParallel(criterion,device_ids=[0,1,2])

Training process is going well, but when i turn to model.eval(), i got explosion of loss.
image
Is there something wrong with model.eval()?

@zhanghang1989
Copy link
Owner

Are you training with evaluation mode?

@mapleneverfade
Copy link
Author

I set model.train() before every epoch of loader.
image

@zhanghang1989
Copy link
Owner

Thx for clarifying! What is the mIoU you were expecting? For example, what is the mIoU when using standard BatchNorm at 1st epoch?

@mapleneverfade
Copy link
Author

image

@zhanghang1989
Copy link
Owner

Am I missing something. You said, "i turn to model.eval(), i got explosion of loss."
What does it mean? We typically do not calculate loss in evaluation mode.

@mapleneverfade
Copy link
Author

Maybe I didn't clear it out. When I use standard BatchNorm I get normal loss both in train mode and eval mode.
While using syn-bn I get norm loss during training but explode in eval mode, it means there maybe
something wrong with syn-bn when turned it to eval mode.
I test the syn-bn model in model.eval(), got this
image
Calculating eval loss is not what i expect to, I just want to figure out what causes the test IoU to be zero.
Or is there something I misused?

@zhanghang1989
Copy link
Owner

Please checkout the PyTorch compatible Synchronized Cross-GPU encoding.nn.BatchNorm2d and the example.

@zhanghang1989
Copy link
Owner

@mapleneverfade The sycBN works the same as standard BN in eval mode. Please try the new PyTorch DataParallel compatible version.

@mapleneverfade
Copy link
Author

I really appreciate for your replying.
But I still don't figure out what's going wrong.
image
Combination of "ModelDataParallel() & CriterionDataParallel() & Standard BN" goes well,
when I replace the "Standard BN" with "encoding.nn.BatchNorm2d",eval-mode still don't work.

@zhanghang1989
Copy link
Owner

Hi, have you checked out the example https://github.com/zhanghang1989/PyTorch-SyncBatchNorm

@zhanghang1989
Copy link
Owner

Hi @mapleneverfade , do you still have the problem? I still couldn't get it why do you calculate loss in eval mode

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

Successfully merging a pull request may close this issue.

2 participants