/
step2Save.py
executable file
·85 lines (71 loc) · 2.76 KB
/
step2Save.py
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
#Copyright (C) 2018 Andreas Mayr
#Licensed under GNU General Public License v3.0 (see http://www.bioinf.jku.at/research/lsc/LICENSE and https://github.com/ml-jku/lsc/blob/master/LICENSE)
if computeTestPredictions:
if compPerformanceTest:
saveFilename=savePrefix+".test.auc.pckl"
saveFile=open(saveFilename, "wb")
pickle.dump(reportTestAUC, saveFile)
saveFile.close()
saveFilename=savePrefix+".test.ap.pckl"
saveFile=open(saveFilename, "wb")
pickle.dump(reportTestAP, saveFile)
saveFile.close()
if computeTrainPredictions:
if compPerformanceTrain:
saveFilename=savePrefix+".train.auc.pckl"
saveFile=open(saveFilename, "wb")
pickle.dump(reportTrainAUC, saveFile)
saveFile.close()
saveFilename=savePrefix+".train.ap.pckl"
saveFile=open(saveFilename, "wb")
pickle.dump(reportTrainAP, saveFile)
saveFile.close()
if logPerformanceAtBestIter:
saveFilename=savePrefix+".eval.auc"
np.save(saveFilename, reportAUCBestIter)
saveFilename=savePrefix+".eval.ap"
np.save(saveFilename, reportAPBestIter)
if savePredictionsAtBestIter:
if useDenseOutputNetPred:
saveFilename=savePrefix+".evalPredict.pckl"
saveFile=open(saveFilename, "wb")
pickle.dump(predDenseBestIter, saveFile)
saveFile.close()
saveFilename=savePrefix+".evalPredict.hdf5"
saveFile=h5py.File(saveFilename, "w")
saveFile.create_dataset('predictions', data=predDenseBestIter)
saveFile.close()
else:
saveFilename=savePrefix+".evalPredict.pckl"
saveFile=open(saveFilename, "wb")
pickle.dump(predSparseBestIter, saveFile)
saveFile.close()
saveFilename=savePrefix+".evalPredict.mtx"
scipy.io.mmwrite(saveFilename, predSparseBestIter)
saveFilename=savePrefix+".eval"
np.savetxt(saveFilename+".cmpNames", np.array(testSamples), fmt="%s")
np.savetxt(saveFilename+".targetNames", np.array(targetAnnInd.index.values), fmt="%s")
if outerFold>=0:
if not (denseOutputData is None):
saveFilename=savePrefix+".evalTrue.hdf5"
saveFile=h5py.File(saveFilename, "w")
saveFile.create_dataset('true', data=testDenseOutput)
saveFile.close()
if not (sparseOutputData is None):
saveFilename=savePrefix+".evalTrue.mtx"
scipy.io.mmwrite(saveFilename, testSparseOutput)
saveFilename=savePrefix+".trainInfo.pckl"
saveFile=open(saveFilename, "wb")
pickle.dump(epoch, saveFile)
pickle.dump(minibatchCounterTrain, saveFile)
pickle.dump(minibatchCounterTest, saveFile)
pickle.dump(minibatchReportNr, saveFile)
saveFile.close()
saveFilename=savePrefix+".trainModel"
with model._get_tf("Graph").as_default():
tf.train.Saver().save(model.session, saveFilename)
saveFilename=savePrefix+"."+finMark+".pckl"
saveFile=open(saveFilename, "wb")
finNr=0
pickle.dump(finNr, saveFile)
saveFile.close()