Skip to content

Commit

Permalink
Merge pull request #39 from SpiNNakerManchester/test-results-to-file
Browse files Browse the repository at this point in the history
add option to dump test results to a file
  • Loading branch information
Luis A. Plana authored Apr 28, 2021
2 parents 95cb091 + 60d3e08 commit c41d29b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions examples/rand10x40/rand10x40.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@

# set recording option
rand10x40.recording_options (rec_test_results = True,
results_file = "rand10x40_test_results.out",
rec_outputs = True,
rec_example_last_tick_only = False
)
Expand Down
23 changes: 23 additions & 0 deletions spinn_pdp2/mlp_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def __init__(self,

# default data recording options
self._rec_test_results = True
self._results_file = None
self._rec_outputs = True
self._rec_example_last_tick_only = False

Expand Down Expand Up @@ -128,6 +129,10 @@ def global_max_ticks (self):
def rec_test_results (self):
return self._rec_test_results

@property
def results_file (self):
return self._results_file

@property
def rec_outputs (self):
return self._rec_outputs
Expand Down Expand Up @@ -425,17 +430,20 @@ def set (self,

def recording_options (self,
rec_test_results = None,
results_file = None,
rec_outputs = None,
rec_example_last_tick_only = None
):
""" set data recording options
:param rec_test_results: record test results
:param results_file: file in which test results should be recorded
:param rec_outputs: record unit outputs
:param rec_example_last_tick_only: record unit outputs only for
last tick of examples
:type rec_test_results: boolean
:type results_file: string
:type rec_outputs: boolean
:type rec_example_last_tick_only: boolean
"""
Expand All @@ -445,6 +453,14 @@ def recording_options (self,
else:
print (f"rec_test_results pre-set to {self._rec_test_results}")

if results_file is not None:
print (f"setting results_file to {results_file}")
self._results_file = results_file
with open(results_file, 'w') as f:
f.write("epoch,numExamples,numTicks,numCorrect\n")
else:
print (f"results_file pre-set to {self._results_file}")

if rec_outputs is not None:
print (f"setting rec_outputs to {rec_outputs}")
self._rec_outputs = rec_outputs
Expand Down Expand Up @@ -768,6 +784,13 @@ def show_test_results (self):
))
print ("--------------------------------------------------\n")

if self._results_file is not None:
with open(self._results_file, 'a') as f:
f.write("{},{},{},{}\n".format(
epochs_trained, examples_tested, ticks_tested,
examples_correct
))


def generate_machine_graph (self):
""" generates a machine graph for the application graph
Expand Down

0 comments on commit c41d29b

Please sign in to comment.