-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsave_individual.py
129 lines (125 loc) · 3.76 KB
/
save_individual.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
def save_individual_101_dnc(f, ind, ind_num, fitness):
f.write('architecture' + str(ind_num) + '\n')
f.write('layers: ')
for op in ind.layers:
f.write(op + ' ')
f.write('\n')
f.write('simplified layers: ')
for op in ind.simplified_layers:
f.write(op + ' ')
f.write('\n')
f.write('connections: ')
for conn in ind.connections:
f.write(str(int(conn)) + ' ')
f.write('\n')
f.write('simplified connection matrix: ')
f.write('\n')
for row in ind.simplified_connection_matrix:
for conn in row:
f.write(str(int(conn)) + ' ')
f.write('\n')
if fitness == 'naswt':
f.write('fitness (naswt score): ')
f.write(str(ind.fitness))
f.write('\n')
f.write('validation accuracy: ')
f.write(str(ind.val_acc))
f.write('\n')
else:
f.write('fitness (validation accuracy): ')
f.write(str(ind.fitness))
f.write('\n')
f.write('test accuracy: ')
f.write(str(ind.test_acc))
f.write('\n')
f.write('train time: ')
f.write(str(ind.train_time))
f.write('\n')
if fitness == 'naswt':
f.write('naswt calculation time: ')
f.write(str(ind.naswt_calc_time))
f.write('\n')
def save_individual_201_dnc(f, ind, ind_num, fitness):
f.write('architecture' + str(ind_num) + '\n')
f.write('layers: ')
for op in ind.layers:
f.write(op + ' ')
f.write('\n')
f.write('simplified layers: ')
for op in ind.simplified_layers:
f.write(op + ' ')
f.write('\n')
f.write('connections: ')
for conn in ind.connections:
f.write(str(int(conn)) + ' ')
f.write('\n')
f.write('simplified connection matrix: ')
f.write('\n')
for row in ind.simplified_connection_matrix:
for conn in row:
f.write(str(int(conn)) + ' ')
f.write('\n')
if fitness == 'naswt':
f.write('fitness (naswt score): ')
f.write(str(ind.fitness))
f.write('\n')
f.write('validation accuracy: ')
f.write(str(ind.val_acc))
f.write('\n')
else:
f.write('fitness (validation accuracy): ')
f.write(str(ind.fitness))
f.write('\n')
f.write('test accuracy: ')
f.write(str(ind.test_acc))
f.write('\n')
f.write('train time: ')
f.write(str(ind.train_time))
f.write('\n')
if fitness == 'naswt':
f.write('naswt calculation time: ')
f.write(str(ind.naswt_calc_time))
f.write('\n')
f.write('train loss: ')
f.write(str(ind.train_loss))
f.write('\n')
f.write('validation loss: ')
f.write(str(ind.val_loss))
f.write('\n')
f.write('test loss: ')
f.write(str(ind.test_loss))
f.write('\n')
f.write('train accuracy: ')
f.write(str(ind.train_acc))
f.write('\n')
f.write('latency: ')
f.write(str(ind.latency))
f.write('\n')
def save_individual_fitness_approximation(f, ind, ind_num, fitness):
f.write('architecture' + str(ind_num) + '\n')
f.write('layers: ')
for op in ind.layers:
f.write(op + ' ')
f.write('\n')
f.write('simplified layers: ')
for op in ind.simplified_layers:
f.write(op + ' ')
f.write('\n')
f.write('connections: ')
for conn in ind.connections:
f.write(str(int(conn)) + ' ')
f.write('\n')
f.write('simplified connection matrix: ')
f.write('\n')
for row in ind.simplified_connection_matrix:
for conn in row:
f.write(str(int(conn)) + ' ')
f.write('\n')
if fitness == 'naswt':
f.write('fitness (approximate naswt score): ')
f.write(str(ind.fitness))
f.write('\n')
else:
f.write('fitness (approximate validation accuracy): ')
f.write(str(ind.fitness))
f.write('\n')