-
Notifications
You must be signed in to change notification settings - Fork 3
/
printAdaptiveparameters.py
46 lines (35 loc) · 1.56 KB
/
printAdaptiveparameters.py
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
import os
from Code.lib.model_RFNet import RFNet
import torch.backends.cudnn as cudnn
from Code.utils.options import opt
import torch
#set the device for training
os.environ["CUDA_VISIBLE_DEVICES"] = opt.gpu_id
print('USE GPU {}'.format(opt.gpu_id))
cudnn.benchmark = True
#build the model
model = RAFNet(32,50)
model.load_state_dict(torch.load('./Checkpoint/RFNet/RFNet_epoch_best.pth'))
print('---------------------------------------')
print('-------RAFNet DCF CA SA adapt Depth qaulity -----------')
with open('Alphas.txt', 'a') as file:
file.write('---------------------------------------\n')
file.write('-------case-2-----------')
fusionNames = ['fu_0','fu_1','fu_2','fu_3','fu_4']
for name,param in model.named_parameters():
# print(name)
for fusionName in fusionNames:
alphaName = fusionName+'.alpha_C'
if alphaName == name:
percentage = param.detach().numpy()[0]
print('Channel Contributes {} in {}.'.format(percentage,fusionName))
file.write('Channel Contributes {} in {}.\n'.format(percentage,fusionName))
alphaName = fusionName+'.alpha_S'
if alphaName == name:
percentage = param.detach().numpy()[0]
print('Spatial Contributes {} in {}.'.format(percentage,fusionName))
file.write('Spatial Contributes {} in {}.\n'.format(percentage,fusionName))
file.write('---------------------------------------\n')
file.write('\n')
file.write('\n')
print('---------------------------------------')