forked from Phalo/PPIN
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcalculate_parameters.py
More file actions
67 lines (58 loc) · 2.86 KB
/
calculate_parameters.py
File metadata and controls
67 lines (58 loc) · 2.86 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
##Model Selection
from MMWUet import MMWUNet
from U2Netnew import U2Net
from Unet_Maw import UNet
from ED_optional import UResnet,BottleNeck,BasicBlock
from Unet_base import UNet_base
import numpy as np
from Unet_concate import UNet_conc
from Unet_GCN import UNet_GCN
from Y_Net import YNet
def get_number_of_learnable_parameters(model):
model_parameters = filter(lambda p: p.requires_grad, model.parameters())
return sum([np.prod(p.size()) for p in model_parameters])
##testing
# Generalize between backbone
# net = UNet(in_channels=1, out_channels=24,bilinear=True,classification=True)
# print('inital Unet_Maw')
# print('the number of trainable parameters: %2f M' % (get_number_of_learnable_parameters(net)/(10**6)))
#
#
# print('inital Unet')
# net = UNet_base(in_channels=1, out_channels=24, bilinear=True, classification=True)
# print('the number of trainable parameters: %2f M' % (get_number_of_learnable_parameters(net)/(10**6)))
#
# print('inital U2net')
# net = U2Net(in_channels=1, out_channels=24,classification=True,classification_gcn=False,classification_only=True)
# print('the number of trainable parameters: %2f M' % (get_number_of_learnable_parameters(net)/(10**6)))
# ## Our proposed method based on U2net
#
#
# print('inital U2net+APL')
# net = U2Net(in_channels=1, out_channels=24,classification=True,classification_gcn=False,classification_only=False)
# print('the number of trainable parameters: %2f M' % (get_number_of_learnable_parameters(net)/(10**6)))
#
#
# print('inital Maw')
# net = MMWUNet(in_channels=1,out_channels=24,classification=True,classification_gcn=True,classification_only=False)
# print('the number of trainable parameters: %2f M' %(get_number_of_learnable_parameters(net)/(10**6)))
# ##2020 MICCAI Liu
# net = UNet_GCN(in_channels=1, out_channels=24, bilinear=True, classification=True)
# print('inital Unet_GCN')
# print('the number of trainable parameters: %2f M' %(get_number_of_learnable_parameters(net)/(10**6)))
# ##2022 MIA Wang
# net = UNet_conc(in_channels=1, out_channels=24, bilinear=True, classification=True)
# print('inital 2020MIA' )
# print('the number of trainable parameters: %2f M' % (get_number_of_learnable_parameters(net)/(10**6)))
# ## 2019 Y-Net
# net = YNet(in_channels=1, out_channels=24, bilinear=True, classification=True)
# print('inital Ynet' )
# print('the number of trainable parameters: %2f M' % (get_number_of_learnable_parameters(net)/(10**6)))
# # 2020 MIA Wang2.0
# net = UResnet(block=BottleNeck, layers=[3, 4, 6, 3], num_classes=24)
# print('UResnet' )
# print('the number of trainable parameters: %2f M' % (get_number_of_learnable_parameters(net)/(10**6)))
## our_all
net =MMWUNet(in_channels=1, out_channels=24,classification=True,classification_gcn=True,classification_only=False)
print('inital baseline')
print('the number of trainable parameters: %2f M' % (get_number_of_learnable_parameters(net)/(10**6)))