ATLAS Offline Software
Loading...
Searching...
No Matches
parseDir.py
Go to the documentation of this file.
1# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
2
3
4from fancyTab import *
5
6def findMin(path):
7 minimum=10000
8 epochWithMinimum=-1
9
10 import os
11 command = "cp "+path+" ."
12 os.system(command)
13 os.system('source cleanFile.sh')
14
15
16 for line in file('chron.txt'):
17 line = line.split()
18 epoch = int(line[0])
19 trainingError = float(line[1])
20 testError = float(line[2])
21 if testError < minimum:
22 minimum = testError
23 epochWithMinimum = epoch
24
25 return epochWithMinimum , minimum
26
27
28
29path="/afs/cern.ch/user/g/giacinto/scratch0/Athena/rel_2/InnerDetector/InDetCalibAlgs/PixelCalibAlgs/NnClusteringCalibration/"
30
31test_table = []
32
33
34import os
35print ("-----------------------------------------------------------------------------------------------------------")
36
37print ("Now looking for the best current minimum of the training in directory: ")
38print (path)
39print ("-----------------------------------------------------------------------------------------------------------")
40print (" ")
41#print ("Network type | \t parameters | \t epoch | \t minimum ")
42test_table.append(["Network Type", "Parameters", "Epoch", "Minimum"])
43
44for dir in [ "number", "positions" , "errors" ]:
45 wh = path+dir
46 listed = [ name for name in os.listdir(wh) if os.path.isdir(os.path.join(wh, name)) ]
47
48 resDir = filter( lambda dirname: dirname[0]!="L" and dirname[0]!="." , listed)
49
50 for weightsDir in resDir:
51 weightPath = wh+"/"+weightsDir
52 listedWeights = [ name for name in os.listdir(weightPath) if os.path.isdir(os.path.join(weightPath , name)) ]
53 filteredListW= filter( lambda dirname: dirname[0]!="L" and dirname[0]!="." , listedWeights)
54 for w in filteredListW:
55 chronFile = weightPath+"/"+w+"/trainingCronology.txt"
56 epochAtMin =-1
57 min =-1
58 if os.path.exists(chronFile):
59 epochAtMin , min = findMin(chronFile)
60 test_table.append([dir,weightsDir ,str(epochAtMin) ,str(min) ])
61
62 test_table.append(["------------","---------------------" ,"------" ,"----------"])
63
64# print (dir+"\t"+weightsDir+"\t"+w+"\t"+str(epochAtMin)+"\t"+str(min))
65# print (dir+" |\t| "+weightsDir+" \t \t "+str(epochAtMin)+" \t "+str(min))
66
67
68print_table(test_table)
69
70
print_table(rows)
Definition fancyTab.py:43
findMin(path)
Definition parseDir.py:6
TFile * file