diff --git a/PlotValidation.m b/PlotValidation.m index 906aeed..5cef5e2 100755 --- a/PlotValidation.m +++ b/PlotValidation.m @@ -4,7 +4,7 @@ % PlotValidation % Generates traing vs validation loss plot. % -% Syntax : PlotValidation.m +% Syntax : PlotValidation.m % % or can be run directly on a log folder of CDeep3M % Syntax : PlotValidation.m ~/trainingdata/1fm/log @@ -19,7 +19,7 @@ % { % [1,1] = train_output.csv % [2,1] = test_output.csv -% [3,1] = output_filepath.png +% [3,1] = output dir % } arg_list = argv (); @@ -27,8 +27,8 @@ 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'); @@ -36,6 +36,7 @@ end else +logdir = arg_list{3,1}; train_file = arg_list{1,1}; test_file = arg_list{2,1}; end @@ -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'); @@ -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); + diff --git a/runvalidation.sh b/runvalidation.sh index ecff7d6..e0d3b23 100755 --- a/runvalidation.sh +++ b/runvalidation.sh @@ -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; @@ -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