-
Notifications
You must be signed in to change notification settings - Fork 10
/
PlotValidation.m
executable file
·86 lines (68 loc) · 2.54 KB
/
PlotValidation.m
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/usr/bin/octave -qf
% PlotValidation
% Generates traing vs validation loss plot.
%
% Syntax : PlotValidation.m <train_output.csv> <validation_output.csv> <log dir>
%
% or can be run directly on a log folder of CDeep3M
% Syntax : PlotValidation.m ~/trainingdata/1fm/log
% => Will create csv files in same log folder and plot of loss.png in same directory
%
%-------------------------------------------------------------------------------
%% Validation for Deep3M -- NCMIR/NBCR, UCSD -- Author: L Tindall -- Date: 5/2018
%-------------------------------------------------------------------------------
%
% arg_list =
% {
% [1,1] = train_output.csv
% [2,1] = test_output.csv
% [3,1] = output dir
% }
arg_list = argv ();
if numel(arg_list) == 0
fprintf('\nSyntax:\n PlotValidation.m <train_output.csv> <validation_output.csv> <output_filepath.png>\nor\nPlotValidation.m ~/trainingdata/1fm/log\n');return
elseif numel(arg_list) == 1
logdir = arg_list{1,1};
if exist(logdir,'dir')==7
disp('Parsing log file');
train_file = fullfile(logdir, 'out.log.train');
test_file = fullfile(logdir, 'out.log.test');
system(sprintf('python ~/caffe_nd_sense_segmentation/tools/extra/parse_log.py %s %s',fullfile(logdir, 'out.log'), logdir));
else
disp('Invalid argument');
return
end
else
logdir = arg_list{3,1};
train_file = arg_list{1,1};
test_file = arg_list{2,1};
end
disp('Reading CSV files');
% column format for train_output csv (NumIters,Seconds,LearningRate,loss_deconv_all)
train_output = csvread(train_file,1,0);
% column format for test_output csv (NumIters,Seconds,LearningRate,accuracy_conv,class_Acc,loss_deconv_all)
test_output = csvread(test_file,1,0);
% Plot loss
plt_loss = figure;
plot(train_output(:,1),train_output(:,4), test_output(:,1), test_output(:,6));
grid on;
set(gca, 'xlabel', 'Number of Iterations');
set(gca, 'ylabel', 'Loss');
set(gca, 'Title', 'Training vs Validation Loss');
set(gca, 'YMinorTick','on', 'YMinorGrid','on');
set(gca,'YScale','log');
legend("Training","Validation");
outfile = fullfile(logdir, 'loss.pdf');
%print(plt_loss,outfile, "-dpngcairo");
print(plt_loss,outfile, "-dpdfcairo");
fprintf('Your loss output file is saved as: %s\n', outfile);
% Plot accuracy
plt_accuracy = figure;
plot(test_output(:,1), test_output(:,4));
grid on;
set(gca, 'xlabel', 'Number of iterations');
set(gca, 'ylabel', 'Accuracy');
set(gca, 'Title', 'Validation Accuracy');
outfile = fullfile(logdir, 'accuracy.pdf');
print(plt_accuracy,outfile, "-dpdfcairo");
fprintf('Your accuracy output file is saved as: %s\n', outfile);