#!/usr/bin/perl -w # # Author: Grant Thiltgen # # This script is to collect output data from the multiple neural nets # run to test our training protocol. use strict; use English; use File::Basename; use Getopt::Long; use Pod::Usage; my $numnets=3; # Number of neural nets to look at. my $txxalign; # The alignment, for example t05-thin90 my $dataset; # The dataset, for example dunbrack-30pc-1763 my $arch; # The architecture of the neural net. my $alphaname; # The name of the alphabet used in neural net training my $data; # Data used, for example tr12 or t1c2 GetOptions( "numnets=i" => \$numnets , "txxalign=s" => \$txxalign , "dataset=s" => \$dataset , "arch=s" => \$arch , "alphaname=s" => \$alphaname , "data=s" => \$data , "help|?" => sub {pod2usage("verbose"=>1);} , "man" => sub {pod2usage("verbose"=>2);} ) or pod2usage("verbose" => 0); # Building loops to create the data file. my $line; # Information from the files brought into this. my $value; # Value of hash for foreach loop. my %trainbits; # storing training data in bits my @temp; # temporary array for storing data in the line. my ($a,$b); # temp values for sorting. my $i=0; # temp value for sorting. my $key; # value for key in hash. my @nets; # Value used to store the nets for checking. my $average=0; # Value for storing average of trained networks. while ($line = ) { chomp $line; $nets[$i++] = $line; } print STDOUT "Net\tValue\n"; print STDOUT "6S\t7N\n"; for (my $i=0; $i < $numnets; $i++) { open (TRAIN, "$nets[$i]/quality-reports/$dataset-$txxalign-$arch-$data-$alphaname-mult250-from-empty.train") or print STDERR "Can't open $data training file for $nets[$i]\n"; while ($line = ) { chomp $line; if ($line =~ /^#/) { next; } else { @temp = split /\s+/, $line; $trainbits{$nets[$i]} = $temp[3]; } } close TRAIN; $average += $trainbits{$nets[$i]}; } $average = $average / $numnets; print STDOUT "avg\t$average\n"; $i = 0; open (NETS, ">networks/$dataset-$txxalign-$arch-$data-$alphaname-mult250.nets"); foreach $key (sort highlow keys %trainbits) { if ($i++ < 1) { print NETS "$key\n"; } print STDOUT "$key\t$trainbits{$key}\n"; } sub highlow ($$) { my ($a,$b) = @_; $trainbits{$b} <=> $trainbits{$a}; } __END__