-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy path5_valid.lua
41 lines (29 loc) · 1 KB
/
5_valid.lua
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
---------- library ----------
require 'torch'
require 'xlua'
---------- functions ----------
function valid()
-- set model to evaluate mode
model:evaluate()
local valid_cleaned_data = torch.Tensor(valid_data:size(1), test_data:size(2), test_data:size(3))
-- test over test data
print('==> validating on test set:')
local valid_nrow = valid_data:size(1)
for t = 1,valid_nrow do
-- disp progress
xlua.progress(t, valid_nrow)
-- get new sample
local input = valid_data[{{t},}]
input = input:cuda()
-- valid sample
local pred = thresholding:forward(model:forward(input))
valid_cleaned_data[{{t,}}] = pred:float()
end
path.mkdir(opt.path_saveimg)
valid_cleaned_images_pred = patch2img(valid_cleaned_data, valid_images)
for i = 1,#valid_cleaned_images_pred do
image.save("save/valid_cleaned_images_" .. i .. ".png", valid_cleaned_images_pred[i])
end
valid_score = calc_rsme(valid_cleaned_images, valid_cleaned_images_pred)
print("valid_score: " .. string.format("%.5f", valid_score))
end