-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
41 lines (33 loc) · 1.03 KB
/
main.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
import sys
from kohonen_network.Trainer import Trainer
from features.decorators import timer, instanciate_globals, print_time_averages, print_time_totals
from kohonen_network.configuration import Configuration
from shell_commands.listener import listen
@timer("Total time: ")
def run(file):
config = Configuration(file)
trainer = Trainer( config )
try:
trainer.train( stop=config.epochs )
except KeyboardInterrupt as e:
print("User cancelled the program.", end="\n")
finally:
if config.visuals:
import matplotlib.pyplot as plt
plt.close("all")
# Print statistics
print_time_totals()
print_time_averages()
# Running tests:
trainer.run_all_tests()
return trainer
if __name__ == '__main__':
# Setup:
for arg in sys.argv:
if "TSP" in arg.upper() or "MNIST" in arg.upper():
file = arg
break
instanciate_globals()
# Running the neural network.
controller = run(file)
listen(controller)