-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresnet_test.py
More file actions
40 lines (38 loc) · 1.02 KB
/
resnet_test.py
File metadata and controls
40 lines (38 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import torch
import torch.backends.cudnn as cudnn
import torch.distributed as dist
import torchvision.models as models
import torch.nn as nn
import os
import time
from multiprocessing import Process
import csv
from gossip_module.utils import flatten_tensors, flatten_tensors_grad, unflatten_tensors, unflatten_tensors_grad
from fsdp_custom import FullyShardedDataParallel as FSDP
from auto_wrap_custom import enable_wrap, auto_wrap, wrap
from torchvision.models.resnet import BasicBlock, ResNet
import argparse
global a
a = 0
def module_check(module):
global a
if (len(list(module.children())) == 0 ):
a += 1
print(module)
for param in module.parameters() :
print(param.data.size())
#print(module.data.size())
for name, child in module.named_children():
module_check(child)
return
if __name__ == '__main__':
model = ResNet(BasicBlock, [2, 2, 2, 2])
model.cuda()
count = 0
for name, p in model.named_parameters() :
if 'weight' in name :
print(name)
count += 1
print(count)
module_check(model)
print(a)