Comments (6)
def convert_model(module):
if isinstance(module, torch.nn.DataParallel):
mod = module.module
mod = convert_model(mod)
mod = DataParallelWithCallback(mod,device_ids=[0,1,2,3]).cuda()
return mod
for pth_module, sync_module in zip([torch.nn.modules.batchnorm.BatchNorm1d,
torch.nn.modules.batchnorm.BatchNorm2d,
torch.nn.modules.batchnorm.BatchNorm3d],
[SynchronizedBatchNorm1d,
SynchronizedBatchNorm2d,
SynchronizedBatchNorm3d]):
if isinstance(module, pth_module):
mod = sync_module(module.num_features, module.eps, module.momentum, module.affine)
mod.running_mean = module.running_mean
mod.running_var = module.running_var
if module.affine:
mod.weight.data = module.weight.data.clone().detach()
mod.bias.data = module.bias.data.clone().detach()
return mod
for name, child in module.named_children():
module.add_module(name, convert_model(child))
return module
this is our version to overcome the problem
from synchronized-batchnorm-pytorch.
Thanks for reporting!
I just tested the current version myself:
from torchvision import models
from sync_batchnorm import convert_model
m = models.resnet18(pretrained=True)
m = convert_model(m)
The codes above run successfully and give the expected output network. Could you please specify the case where our current vision fails? That will be deeply appreciated! Thanks!
from synchronized-batchnorm-pytorch.
Traceback (most recent call last):
File "sbn.py", line 7, in
m = convert_model(m)
File "/home/workspace/xxx/utils/sync_batchnorm/batchnorm.py", line 360, in convert_model
mod.add_module(name, convert_model(child))
UnboundLocalError: local variable 'mod' referenced before assignment
from synchronized-batchnorm-pytorch.
@Re3write Can you make sure that you have this line in your file?
It looks to me that you somehow deleted this line?
from synchronized-batchnorm-pytorch.
@vacancy sorry, the code we use dont has the line , maybe we accidentally deleted it.
from synchronized-batchnorm-pytorch.
No worries. Best luck!
from synchronized-batchnorm-pytorch.
Related Issues (20)
- test gap between training and test HOT 3
- Is this a bug that channel between input tensor and sync batchnorm are mismatch the code still run successful? HOT 2
- How to cite this repo in bib?
- How to use it when testing HOT 1
- RuntimeError with convert_model - "found one of them on device: cpu" HOT 2
- Thinking about 'sync_batchnorm.batchnorm.convert_model(module)'.. HOT 1
- Wired things, module must have its parameters and buffers on device cuda:0 (device_ids[0]) but found one of them on device: cpu HOT 1
- Question on `sqrt(max(var, eps))` HOT 2
- module问题
- Training cannot start HOT 7
- Training cannot start
- batchnor while using distributed dataparallel HOT 1
- a question about the highlight "use sqrt(max(var, eps)) instead of sqrt(var + eps)" HOT 4
- Train Stucked HOT 4
- raining couldn 't start HOT 2
- Training stuck with multiple call of forward function HOT 7
- Where is "track_running_stats" implementation code? HOT 1
- how to export with onnx
- .
- spam
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from synchronized-batchnorm-pytorch.