Skip to content

Commit

Permalink
Added code for plotting accuracy
Browse files Browse the repository at this point in the history
  • Loading branch information
ltindall committed May 7, 2018
1 parent 8634c35 commit 0d64652
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 18 deletions.
42 changes: 30 additions & 12 deletions PlotValidation.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
% PlotValidation
% Generates traing vs validation loss plot.
%
% Syntax : PlotValidation.m <train_output.csv> <validation_output.csv> <output_filepath.png>
% 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
Expand All @@ -19,23 +19,24 @@
% {
% [1,1] = train_output.csv
% [2,1] = test_output.csv
% [3,1] = output_filepath.png
% [3,1] = output dir
% }
arg_list = argv ();

if 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'); delete(train_file);
test_file = fullfile(logdir, 'out.log.test'); delete(test_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
Expand All @@ -47,7 +48,9 @@
% column format for test_output csv (NumIters,Seconds,LearningRate,accuracy_conv,class_Acc,loss_deconv_all)
test_output = csvread(test_file,1,0);

plt = figure;

% 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');
Expand All @@ -57,11 +60,26 @@
set(gca,'YScale','log');
legend("Training","Validation");

if numel(arg_list)==3
outfile = arg_list{3,1};
elseif numel(arg_list)==1
outfile = fullfile(logdir, 'loss');
end
%print(plt,outfile, "-dpngcairo");
print(plt,outfile, "-dpdf");
fprintf('Your outputfile is saved as: %s.pdf\n', outfile');

print(plt_loss,outfile, "-dpngcairo");
%print(plt_loss,outfile, "-dpdf");
fprintf('Your loss output file is saved as: %s.png\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');
print(plt_accuracy,outfile, "-dpngcairo");
fprintf('Your accuracy output file is saved as: %s.png\n', outfile);

12 changes: 6 additions & 6 deletions runvalidation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ fi

function usage()
{
echo "usage: $script_name log_file out_file
echo "usage: $script_name log_file out_dir
Script to plot training vs validation loss.
Example: runvalidation.sh ~/cdeep3m/train_out/1fm/log/out.log ~/cdeep3m/train_out/1fm/train_vs_val.png
Script to plot training vs validation loss.
Example: runvalidation.sh ~/cdeep3m/train_out/1fm/log/out.log ~/cdeep3m/train_out/1fm/log/
Version: $version
positional arguments:
log_file Log file from desired model.
out_file Filename of output png.
log_file Log file from desired model.
out_dir Directory for output files
" 1>&2;
Expand All @@ -34,7 +34,7 @@ fi
log_dir=$(dirname $1)


python $CAFFE_PATH/tools/extra/parse_log.py $1 $log_dir
python $CAFFE_PATH/tools/extra/parse_log.py $1 $log_dir


PlotValidation.m $1.train $1.test $2

0 comments on commit 0d64652

Please sign in to comment.