/test/agg_tests.py

https://github.com/pnnl/safekit · Python · 259 lines · 208 code · 44 blank · 7 comment · 34 complexity · a1dd72fea61f46eaa92693efc71543f8 MD5 · raw file

  1. """
  2. """
  3. import os
  4. import argparse
  5. parser = argparse.ArgumentParser()
  6. parser.add_argument('lanl_datapath', type=str, help="path to lanl parent directory of aggregate model features.")
  7. parser.add_argument('cert_datapath', type=str, help="path to cert parent directory of aggregate model features.")
  8. parser.add_argument('logfile', type=str, help="File to write stderr messages.")
  9. args = parser.parse_args()
  10. if not args.lanl_datapath.endswith('/'):
  11. args.lanl_datapath += '/'
  12. if not args.cert_datapath.endswith('/'):
  13. args.cert_datapath += '/'
  14. modelpath = '/'.join(os.path.realpath(__file__).split('/')[:-2]) + '/safekit/models'
  15. specpath = '/'.join(os.path.realpath(__file__).split('/')[:-2]) + '/safekit/features/specs/agg'
  16. num_finished = 0
  17. all_okay = 0
  18. # =================================cert agg dnn stuff==================================================================
  19. with open(args.logfile, 'a') as log:
  20. log.write('cert dnn autoencoder w/diag covariance, batch norm, input norm, replay\n\n\n')
  21. print('\n\ncert dnn autoencoder w/diag covariance, batch norm, input norm, replay\n\n\n')
  22. ok = os.system('python %s/dnn_agg.py %scert_head.csv /tmp %s/cert_all_in_all_out_agg.json -dist diag -norm batch -replay 2>> %s' % (modelpath, args.cert_datapath, specpath, args.logfile))
  23. num_finished += ok == 0
  24. all_okay += ok != 0
  25. with open(args.logfile, 'a') as log:
  26. log.write('cert dnn autoencoder w/diag covariance, batch norm, input norm\n\n\n')
  27. print('\n\ncert dnn autoencoder w/diag covariance, batch norm, input norm\n\n\n')
  28. ok = os.system('python %s/dnn_agg.py %scert_head.csv /tmp %s/cert_all_in_all_out_agg.json -dist diag -input_norm -alpha 0.5 -norm batch 2>> %s' % (modelpath, args.cert_datapath, specpath, args.logfile))
  29. num_finished += ok == 0
  30. all_okay += ok != 0
  31. with open(args.logfile, 'a') as log:
  32. log.write('cert dnn autoencoder w/diag covariance, layer norm, input norm\n\n\n')
  33. print('\n\ncert dnn autoencoder w/diag covariance, layer norm, input norm\n\n\n')
  34. ok = os.system('python %s/dnn_agg.py %scert_head.csv /tmp %s/cert_all_in_all_out_agg.json -dist diag -input_norm -alpha 0.5 -norm layer 2>> %s' % (modelpath, args.cert_datapath, specpath, args.logfile))
  35. num_finished += ok == 0
  36. all_okay += ok != 0
  37. with open(args.logfile, 'a') as log:
  38. log.write('\n\ncert dnn autoencoder w/ identity covariance, no model norm, input norm\n\n\n')
  39. print('\n\ncert dnn autoencoder w/ identity covariance, no model norm, input norm\n\n\n')
  40. ok = os.system('python %s/dnn_agg.py %scert_head.csv /tmp %s/cert_all_in_all_out_agg.json -dist ident -input_norm -alpha 0.5 2>> %s' % (modelpath, args.cert_datapath, specpath, args.logfile))
  41. num_finished += ok == 0
  42. all_okay += ok != 0
  43. with open(args.logfile, 'a') as log:
  44. log.write('cert dnn autoencoder w/ full covariance, no model norm, no input norm\n\n\n')
  45. print('\n\ncert dnn autoencoder w/ full covariance, no model norm, no input norm\n\n\n')
  46. ok = os.system('python %s/dnn_agg.py %scert_head.csv /tmp %s/cert_all_in_all_out_agg.json -dist full -input_norm -alpha 0.5 2>> %s' % (modelpath, args.cert_datapath, specpath, args.logfile))
  47. num_finished += ok == 0
  48. all_okay += ok != 0
  49. with open(args.logfile, 'a') as log:
  50. log.write('cert dnn autoencoder w/ diag covariance, no model norm, no input norm\n\n\n')
  51. print('\n\ncert dnn autoencoder w/ diag covariance, no model norm, no input norm\n\n\n')
  52. ok = os.system('python %s/dnn_agg.py %scert_head.csv /tmp %s/cert_all_in_all_out_agg.json -dist diag 2>> %s' % (modelpath, args.cert_datapath, specpath, args.logfile))
  53. num_finished += ok == 0
  54. all_okay += ok != 0
  55. with open(args.logfile, 'a') as log:
  56. log.write('cert dnn autoencoder w/ identity covariance, no model norm, no input norm\n\n\n')
  57. print('\n\ncert dnn autoencoder w/ identity covariance, no model norm, no input norm\n\n\n')
  58. ok = os.system('python %s/dnn_agg.py %scert_head.csv /tmp %s/cert_all_in_all_out_agg.json -dist ident 2>> %s' % (modelpath, args.cert_datapath, specpath, args.logfile))
  59. num_finished += ok == 0
  60. all_okay += ok != 0
  61. with open(args.logfile, 'a') as log:
  62. log.write('cert dnn autoencoder w/ full covariance, no model norm, no input norm\n\n\n')
  63. print('\n\ncert dnn autoencoder w/ full covariance, no model norm, no input norm\n\n\n')
  64. ok = os.system('python %s/dnn_agg.py %scert_head.csv /tmp %s/cert_all_in_all_out_agg.json -dist full 2>> %s' % (modelpath, args.cert_datapath, specpath, args.logfile))
  65. num_finished += ok == 0
  66. all_okay += ok != 0
  67. # lanl agg dnn stuff
  68. with open(args.logfile, 'a') as log:
  69. log.write('dnn autoencoder w/diag covariance, batch norm, input norm, replay\n\n\n')
  70. print('\n\ndnn autoencoder w/diag covariance, batch norm, input norm, replay\n\n\n')
  71. ok = os.system('python %s/dnn_agg.py %slanl_agg_head.txt /tmp %s/lanl_count_in_count_out_agg.json -dist diag -norm batch -replay -delimiter , -skipheader 2>> %s' % (modelpath, args.lanl_datapath, specpath, args.logfile))
  72. num_finished += ok == 0
  73. all_okay += ok != 0
  74. with open(args.logfile, 'a') as log:
  75. log.write('dnn autoencoder w/diag covariance, batch norm, input norm\n\n\n')
  76. print('\n\ndnn autoencoder w/diag covariance, batch norm, input norm\n\n\n')
  77. ok = os.system('python %s/dnn_agg.py %slanl_agg_head.txt /tmp %s/lanl_count_in_count_out_agg.json -dist diag -input_norm -alpha 0.5 -norm batch -delimiter , -skipheader 2>> %s' % (modelpath, args.lanl_datapath, specpath, args.logfile))
  78. num_finished += ok == 0
  79. all_okay += ok != 0
  80. with open(args.logfile, 'a') as log:
  81. log.write('dnn autoencoder w/diag covariance, layer norm, input norm\n\n\n')
  82. print('\n\ndnn autoencoder w/diag covariance, layer norm, input norm\n\n\n')
  83. ok = os.system('python %s/dnn_agg.py %slanl_agg_head.txt /tmp %s/lanl_count_in_count_out_agg.json -dist diag -input_norm -alpha 0.5 -norm layer -delimiter , -skipheader 2>> %s' % (modelpath, args.lanl_datapath, specpath, args.logfile))
  84. num_finished += ok == 0
  85. all_okay += ok != 0
  86. with open(args.logfile, 'a') as log:
  87. log.write('dnn autoencoder w/ identity covariance, no model norm, input norm\n\n\n')
  88. print('\n\ndnn autoencoder w/ identity covariance, no model norm, input norm\n\n\n')
  89. ok = os.system('python %s/dnn_agg.py %slanl_agg_head.txt /tmp %s/lanl_count_in_count_out_agg.json -dist ident -input_norm -alpha 0.5 -delimiter , -skipheader 2>> %s' % (modelpath, args.lanl_datapath, specpath, args.logfile))
  90. num_finished += ok == 0
  91. all_okay += ok != 0
  92. with open(args.logfile, 'a') as log:
  93. log.write('dnn autoencoder w/ full covariance, no model norm, input norm\n\n\n')
  94. print('\n\ndnn autoencoder w/ full covariance, no model norm, input norm\n\n\n')
  95. ok = os.system('python %s/dnn_agg.py %slanl_agg_head.txt /tmp %s/lanl_count_in_count_out_agg.json -dist full -input_norm -alpha 0.5 -delimiter , -skipheader 2>> %s' % (modelpath, args.lanl_datapath, specpath, args.logfile))
  96. num_finished += ok == 0
  97. all_okay += ok != 0
  98. with open(args.logfile, 'a') as log:
  99. log.write('dnn autoencoder w/ diag covariance, no model norm, no input norm\n\n\n')
  100. print('\n\ndnn autoencoder w/ diag covariance, no model norm, no input norm\n\n\n')
  101. ok = os.system('python %s/dnn_agg.py %slanl_agg_head.txt /tmp %s/lanl_count_in_count_out_agg.json -dist diag -delimiter , -skipheader 2>> %s' % (modelpath, args.lanl_datapath, specpath, args.logfile))
  102. num_finished += ok == 0
  103. all_okay += ok != 0
  104. with open(args.logfile, 'a') as log:
  105. log.write('dnn autoencoder w/ identity covariance, no model norm, no input norm\n\n\n')
  106. print('\n\ndnn autoencoder w/ identity covariance, no model norm, no input norm\n\n\n')
  107. ok = os.system('python %s/dnn_agg.py %slanl_agg_head.txt /tmp %s/lanl_count_in_count_out_agg.json -dist ident -delimiter , -skipheader 2>> %s' % (modelpath, args.lanl_datapath, specpath, args.logfile))
  108. num_finished += ok == 0
  109. all_okay += ok != 0
  110. with open(args.logfile, 'a') as log:
  111. log.write('dnn autoencoder w/ full covariance, no model norm, no input norm\n\n\n')
  112. print('\n\ndnn autoencoder w/ full covariance, no model norm, no input norm\n\n\n')
  113. ok = os.system('python %s/dnn_agg.py %slanl_agg_head.txt /tmp %s/lanl_count_in_count_out_agg.json -dist full -delimiter , -skipheader 2>> %s' % (modelpath, args.lanl_datapath, specpath, args.logfile))
  114. num_finished += ok == 0
  115. all_okay += ok != 0
  116. # ==========================================cert agg lstm stuff=====================================================
  117. with open(args.logfile, 'a') as log:
  118. log.write('cert rnn autoencoder w/diag covariance, batch norm, input norm, replay\n\n\n')
  119. print('\n\ncert rnn autoencoder w/diag covariance, batch norm, input norm, replay\n\n\n')
  120. ok = os.system('python %s/lstm_agg.py %scert_head.csv /tmp %s/cert_all_in_all_out_agg.json -dist diag -norm batch -replay_ratio 2 2 2>> %s' % (modelpath, args.cert_datapath, specpath, args.logfile))
  121. num_finished += ok == 0
  122. all_okay += ok != 0
  123. with open(args.logfile, 'a') as log:
  124. log.write('cert rnn autoencoder w/diag covariance, batch norm, input norm\n\n\n')
  125. print('\n\ncert rnn autoencoder w/diag covariance, batch norm, input norm\n\n\n')
  126. ok = os.system('python %s/lstm_agg.py %scert_head.csv /tmp %s/cert_all_in_all_out_agg.json -dist diag -input_norm -alpha 0.5 -norm batch 2>> %s' % (modelpath, args.cert_datapath, specpath, args.logfile))
  127. num_finished += ok == 0
  128. all_okay += ok != 0
  129. with open(args.logfile, 'a') as log:
  130. log.write('cert rnn autoencoder w/diag covariance, layer norm, input norm\n\n\n')
  131. print('\n\ncert rnn autoencoder w/diag covariance, layer norm, input norm\n\n\n')
  132. ok = os.system('python %s/lstm_agg.py %scert_head.csv /tmp %s/cert_all_in_all_out_agg.json -dist diag -input_norm -alpha 0.5 -norm layer 2>> %s' % (modelpath, args.cert_datapath, specpath, args.logfile))
  133. num_finished += ok == 0
  134. all_okay += ok != 0
  135. with open(args.logfile, 'a') as log:
  136. log.write('cert rnn autoencoder w/ identity covariance, no model norm, input norm\n\n\n')
  137. print('\n\ncert rnn autoencoder w/ identity covariance, no model norm, input norm\n\n\n')
  138. ok = os.system('python %s/lstm_agg.py %scert_head.csv /tmp %s/cert_all_in_all_out_agg.json -dist ident -input_norm -alpha 0.5 2>> %s' % (modelpath, args.cert_datapath, specpath, args.logfile))
  139. num_finished += ok == 0
  140. all_okay += ok != 0
  141. with open(args.logfile, 'a') as log:
  142. log.write('cert rnn autoencoder w/ full covariance, no model norm, input norm\n\n\n')
  143. print('\n\ncert rnn autoencoder w/ full covariance, no model norm, input norm\n\n\n')
  144. ok = os.system('python %s/lstm_agg.py %scert_head.csv /tmp %s/cert_all_in_all_out_agg.json -dist full -input_norm -alpha 0.5 2>> %s' % (modelpath, args.cert_datapath, specpath, args.logfile))
  145. num_finished += ok == 0
  146. all_okay += ok != 0
  147. with open(args.logfile, 'a') as log:
  148. log.write('cert rnn autoencoder w/ diag covariance, no model norm, no input norm\n\n\n')
  149. print('\n\ncert rnn autoencoder w/ diag covariance, no model norm, no input norm\n\n\n')
  150. ok = os.system('python %s/lstm_agg.py %scert_head.csv /tmp %s/cert_all_in_all_out_agg.json -dist diag 2>> %s' % (modelpath, args.cert_datapath, specpath, args.logfile))
  151. num_finished += ok == 0
  152. all_okay += ok != 0
  153. with open(args.logfile, 'a') as log:
  154. log.write('cert rnn dnn autoencoder w/ identity covariance, no model norm, no input norm\n\n\n')
  155. print('\n\ncert rnn dnn autoencoder w/ identity covariance, no model norm, no input norm\n\n\n')
  156. ok = os.system('python %s/lstm_agg.py %scert_head.csv /tmp %s/cert_all_in_all_out_agg.json -dist ident 2>> %s' % (modelpath, args.cert_datapath, specpath, args.logfile))
  157. num_finished += ok == 0
  158. all_okay += ok != 0
  159. with open(args.logfile, 'a') as log:
  160. log.write('cert rnn dnn autoencoder w/ full covariance, no model norm, no input norm\n\n\n')
  161. print('\n\ncert rnn dnn autoencoder w/ full covariance, no model norm, no input norm\n\n\n')
  162. ok = os.system('python %s/lstm_agg.py %scert_head.csv /tmp %s/cert_all_in_all_out_agg.json -dist full 2>> %s' % (modelpath, args.cert_datapath, specpath, args.logfile))
  163. num_finished += ok == 0
  164. all_okay += ok != 0
  165. # ======================================lanl agg rnn stuff=======================================================
  166. with open(args.logfile, 'a') as log:
  167. log.write('rnn autoencoder w/diag covariance, batch norm, input norm, replay\n\n\n')
  168. print('\n\nrnn autoencoder w/diag covariance, batch norm, input norm, replay\n\n\n')
  169. ok = os.system('python %s/lstm_agg.py %slanl_agg_head.txt /tmp %s/lanl_count_in_count_out_agg.json -dist diag -norm batch -replay_ratio 2 2 -delimiter , -skipheader 2>> %s' % (modelpath, args.lanl_datapath, specpath, args.logfile))
  170. num_finished += ok == 0
  171. all_okay += ok != 0
  172. with open(args.logfile, 'a') as log:
  173. log.write('rnn autoencoder w/diag covariance, batch norm, input norm\n\n\n')
  174. print('\n\nrnn autoencoder w/diag covariance, batch norm, input norm\n\n\n')
  175. ok = os.system('python %s/lstm_agg.py %slanl_agg_head.txt /tmp %s/lanl_count_in_count_out_agg.json -dist diag -alpha 0.5 -norm batch -input_norm -delimiter , -skipheader 2>> %s' % (modelpath, args.lanl_datapath, specpath, args.logfile))
  176. num_finished += ok == 0
  177. all_okay += ok != 0
  178. with open(args.logfile, 'a') as log:
  179. log.write('rnn autoencoder w/diag covariance, layer norm, input norm\n\n\n')
  180. print('\n\nrnn autoencoder w/diag covariance, layer norm, input norm\n\n\n')
  181. ok = os.system('python %s/lstm_agg.py %slanl_agg_head.txt /tmp %s/lanl_count_in_count_out_agg.json -dist diag -input_norm -alpha 0.5 -norm layer -delimiter , -skipheader 2>> %s' % (modelpath, args.lanl_datapath, specpath, args.logfile))
  182. num_finished += ok == 0
  183. all_okay += ok != 0
  184. with open(args.logfile, 'a') as log:
  185. log.write('rnn autoencoder w/ identity covariance, no model norm, input norm\n\n\n')
  186. print('\n\nrnn autoencoder w/ identity covariance, no model norm, input norm\n\n\n')
  187. ok = os.system('python %s/lstm_agg.py %slanl_agg_head.txt /tmp %s/lanl_count_in_count_out_agg.json -dist ident -input_norm -alpha 0.5 -delimiter , -skipheader 2>> %s' % (modelpath, args.lanl_datapath, specpath, args.logfile))
  188. num_finished += ok == 0
  189. all_okay += ok != 0
  190. with open(args.logfile, 'a') as log:
  191. log.write('rnn autoencoder w/ full covariance, no model norm, input norm\n\n\n')
  192. print('\n\nrnn autoencoder w/ full covariance, no model norm, input norm\n\n\n')
  193. ok = os.system('python %s/lstm_agg.py %slanl_agg_head.txt /tmp %s/lanl_count_in_count_out_agg.json -dist full -input_norm -alpha 0.5 -delimiter , -skipheader 2>> %s' % (modelpath, args.lanl_datapath, specpath, args.logfile))
  194. num_finished += ok == 0
  195. all_okay += ok != 0
  196. with open(args.logfile, 'a') as log:
  197. log.write('rnn autoencoder w/ diag covariance, no model norm, no input norm\n\n\n')
  198. print('\n\nrnn autoencoder w/ diag covariance, no model norm, no input norm\n\n\n')
  199. ok = os.system('python %s/lstm_agg.py %slanl_agg_head.txt /tmp %s/lanl_count_in_count_out_agg.json -dist diag -delimiter , -skipheader 2>> %s' % (modelpath, args.lanl_datapath, specpath, args.logfile))
  200. num_finished += ok == 0
  201. all_okay += ok != 0
  202. with open(args.logfile, 'a') as log:
  203. log.write('rnn autoencoder w/ identity covariance, no model norm, no input norm\n\n\n')
  204. print('\n\nrnn autoencoder w/ identity covariance, no model norm, no input norm\n\n\n')
  205. ok = os.system('python %s/lstm_agg.py %slanl_agg_head.txt /tmp %s/lanl_count_in_count_out_agg.json -dist ident -delimiter , -skipheader 2>> %s' % (modelpath, args.lanl_datapath, specpath, args.logfile))
  206. num_finished += ok == 0
  207. all_okay += ok != 0
  208. with open(args.logfile, 'a') as log:
  209. log.write('rnn autoencoder w/ full covariance, no model norm, no input norm\n\n\n')
  210. print('\n\nrnn autoencoder w/ full covariance, no model norm, no input norm\n\n\n')
  211. ok = os.system('python %s/lstm_agg.py %slanl_agg_head.txt /tmp %s/lanl_count_in_count_out_agg.json -dist full -delimiter , -skipheader 2>> %s' % (modelpath, args.lanl_datapath, specpath, args.logfile))
  212. num_finished += ok == 0
  213. all_okay += ok != 0
  214. print('Number finished: %s\nNumber failed: %s' % (num_finished, all_okay))