-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot_training.pl
More file actions
executable file
·150 lines (104 loc) · 3.33 KB
/
Copy pathplot_training.pl
File metadata and controls
executable file
·150 lines (104 loc) · 3.33 KB
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#!/usr/bin/perl
use strict;
use warnings;
my $log = shift or die "Uso: perl plot_training.pl training.log\n";
open(my $IN, "<", $log) or die "Cannot open $log\n";
open(my $OUT, ">", "training.dat") or die "Cannot create training.dat\n";
print $OUT "#epoch train_acc train_mse val_acc val_mse test_acc test_mse\n";
while(<$IN>){
if(/epoch\s+(\d+)\s+\|\s+
train_acc:\s+([0-9.eE+-]+)\s+
train_mse:\s+([0-9.eE+-]+)\s+\|\s+
val_acc:\s+([0-9.eE+-]+)\s+
val_mse:\s+([0-9.eE+-]+)\s+
test_acc:\s+([0-9.eE+-]+)\s+\|\s+
test_mse:\s+([0-9.eE+-]+)/x){
print $OUT "$1 $2 $3 $4 $5 $6 $7\n";
}
}
close($IN);
close($OUT);
open(my $GP, "|-", "gnuplot") or die "Cannot start gnuplot\n";
print $GP <<'EOF';
set terminal pngcairo size 1400,800 enhanced font "Arial,12"
set grid
set border linewidth 1.5
set key outside
set tics out
#####################################################
# ACCURACY
#####################################################
set output "accuracy.png"
set title "MLP Accuracy"
set xlabel "Epoch"
set ylabel "Accuracy"
set yrange [0:1]
plot \
"training.dat" using 1:2 with linespoints lw 2 pt 7 ps 0.8 title "Training", \
"training.dat" using 1:4 with linespoints lw 2 pt 5 ps 0.8 title "Validation", \
"training.dat" using 1:6 with linespoints lw 2 pt 9 ps 0.8 title "Test"
#####################################################
# MSE
#####################################################
set output "mse.png"
set title "MLP Mean Squared Error"
set xlabel "Epoch"
set ylabel "MSE"
plot \
"training.dat" using 1:3 with linespoints lw 2 pt 7 ps 0.8 title "Training", \
"training.dat" using 1:5 with linespoints lw 2 pt 5 ps 0.8 title "Validation", \
"training.dat" using 1:7 with linespoints lw 2 pt 9 ps 0.8 title "Test"
EOF
close($GP);
print "\nGenerated:\n";
print " training.dat\n";
print " accuracy.png\n";
print " mse.png\n";#!/usr/bin/perl
use strict;
use warnings;
my $log = shift or die "Uso: perl plot_training.pl training.log\n";
open(my $IN, "<", $log) or die "Impossibile aprire $log\n";
open(my $OUT, ">", "training.dat") or die "Impossibile creare training.dat\n";
print $OUT "# epoch train_acc train_mse val_acc val_mse\n";
while(<$IN>){
if(/epoch\s+(\d+)\s+\|\s+
train_acc:\s+([0-9.eE+-]+)\s+
train_mse:\s+([0-9.eE+-]+)\s+\|\s+
val_acc:\s+([0-9.eE+-]+)\s+
val_mse:\s+([0-9.eE+-]+)/x){
print $OUT "$1 $2 $3 $4 $5\n";
}
}
close($IN);
close($OUT);
open(my $GP, "|-", "gnuplot") or die "Impossibile avviare gnuplot\n";
print $GP <<'EOF';
set terminal pngcairo size 1200,700 enhanced
set grid
set key left top
############################################
# Accuracy
############################################
set output "accuracy.png"
set title "Training Accuracy"
set xlabel "Epoch"
set ylabel "Accuracy"
plot \
"training.dat" using 1:2 with lines lw 3 title "Train", \
"training.dat" using 1:4 with lines lw 3 title "Validation"
############################################
# MSE
############################################
set output "mse.png"
set title "Training MSE"
set xlabel "Epoch"
set ylabel "MSE"
plot \
"training.dat" using 1:3 with lines lw 3 title "Train", \
"training.dat" using 1:5 with lines lw 3 title "Validation"
EOF
close($GP);
print "Creati:\n";
print " training.dat\n";
print " accuracy.png\n";
print " mse.png\n";