@@ -24,7 +24,7 @@ def __init__(self):
24
24
self .MAX_FANOUT = 1
25
25
self .NUM_EPOCHS = 1
26
26
self .BATCH_SIZE = 1
27
- self .SHUFFLE_BUFFER = 0
27
+ self .SHUFFLE_SEED = 0
28
28
self .LR = 0.1
29
29
self .TARGET = 50
30
30
self .TEST_PERIOD = 1
@@ -62,7 +62,7 @@ def prep(self):
62
62
self .MAX_FANOUT = math .ceil (options ['system' ]['MAX_THREADS' ]) # controlls multi-threading
63
63
self .NUM_EPOCHS = math .ceil (options ['model' ]['NUM_LOCAL_EPOCHS' ]) # for client model
64
64
self .BATCH_SIZE = math .ceil (options ['model' ]['LOCAL_BATCH_SIZE' ]) # for client model
65
- self .SHUFFLE_BUFFER = math .ceil (options ['model' ]['SHUFFLE_BUFFER ' ])
65
+ self .SHUFFLE_SEED = math .ceil (options ['model' ]['SHUFFLE_SEED ' ])
66
66
self .LR = options ['model' ]['LEARNING_RATE' ] # SGD learning rate
67
67
self .TARGET = options ['model' ]['TARGET_ACCURACY' ] # target accuracy for model when tested with test set
68
68
self .TEST_PERIOD = options ['model' ]['ROUNDS_BETWEEN_TESTS' ] # number of rounds between testset evaluation
@@ -97,16 +97,16 @@ def test_num(self, n):
97
97
98
98
# construct value array
99
99
# learning rate chosen/iterates first, batch size second, ...
100
- shuffle_buffer = [ 100 , 200 , 300 , 400 , 500 , 600 , 700 , 800 ]
101
- percent_data_iid = [0 , 20 , 40 , 60 , 80 , 100 ] # schema 1
100
+ shuffle_seed = list ( range ( 30 ))
101
+ percent_data_iid = [20 , 40 , 60 , 80 , 100 ] # schema 1
102
102
percent_clients_iid = [50 ] # schema 2
103
- cohort_size = [2 , 5 , 10 , 15 , 20 , 25 , 30 ]
103
+ cohort_size = [2 , 5 , 10 , 12 , 14 , 16 , 18 , 20 , 22 , 24 , 26 , 28 , 30 , 35 , 40 ]
104
104
num_epochs = [10 ] # leave at 10
105
105
batch_size = [10 ]
106
106
learning_rate = [0.1 ]
107
107
108
108
# convert test number to array indices and set constants to array values
109
- self .SHUFFLE_BUFFER = shuffle_buffer [n // (len (percent_data_iid ) * len (percent_clients_iid ) * len (cohort_size ) * len (num_epochs ) * len (batch_size ) * len (learning_rate ))]
109
+ self .SHUFFLE_SEED = shuffle_seed [n // (len (percent_data_iid ) * len (percent_clients_iid ) * len (cohort_size ) * len (num_epochs ) * len (batch_size ) * len (learning_rate ))]
110
110
n = n % (len (percent_data_iid ) * len (percent_clients_iid ) * len (cohort_size ) * len (num_epochs ) * len (batch_size ) * len (learning_rate ))
111
111
self .PERCENT_DATA_IID = percent_data_iid [n // (len (percent_clients_iid ) * len (cohort_size ) * len (num_epochs ) * len (batch_size ) * len (learning_rate ))]
112
112
n = n % (len (percent_clients_iid ) * len (cohort_size ) * len (num_epochs ) * len (batch_size ) * len (learning_rate ))
@@ -132,11 +132,11 @@ def make_config_csv(self, test, batch):
132
132
filename = 'results/' + str (batch ) + '/' + str (batch ) + '.' + str (test ) + '.config.csv'
133
133
with open (filename , 'w' , newline = '' ) as csvfile :
134
134
writer = csv .writer (csvfile , delimiter = ',' , quotechar = '|' , quoting = csv .QUOTE_MINIMAL )
135
- writer .writerow (['COHORT_SIZE' , 'NUM_LOCAL_EPOCHS' , 'LOCAL_BATCH_SIZE' , 'SHUFFLE_BUFFER ' ,
135
+ writer .writerow (['COHORT_SIZE' , 'NUM_LOCAL_EPOCHS' , 'LOCAL_BATCH_SIZE' , 'SHUFFLE_SEED ' ,
136
136
'LEARNING_RATE' , 'TARGET_ACCURACY' , 'ROUNDS_BETWEEN_TESTS' , 'NUM_CLIENTS' , 'NUM_CLASSES_PER' ,
137
137
'MEAN_NUM_DATA_PTS_PER_CLIENT' , 'STD_DEV_NUM_DATA_PTS_PER_CLIENT' , 'PERCENT_DATA_IID' ,
138
138
'PERCENT_CLIENTS_IID' ,'MAX_THREADS' ])
139
- writer .writerow ([self .COHORT_SIZE , self .NUM_EPOCHS , self .BATCH_SIZE , self .SHUFFLE_BUFFER ,
139
+ writer .writerow ([self .COHORT_SIZE , self .NUM_EPOCHS , self .BATCH_SIZE , self .SHUFFLE_SEED ,
140
140
self .LR , self .TARGET , self .TEST_PERIOD , self .CLIENTS , self .SHARDS ,
141
141
self .NUMDATAPTS_MEAN , self .NUMDATAPTS_STDEV , self .PERCENT_DATA_IID ,
142
142
self .PERCENT_CLIENTS_IID , self .MAX_FANOUT ])
@@ -155,7 +155,7 @@ def load_data(self):
155
155
156
156
# create sample batch for Keras model wrapper
157
157
# note: sample batch is different data type than dataset used in iterative process
158
- self .sample_batch = tf .nest .map_structure (lambda x : x .numpy (), iter (dataset .repeat (self .NUM_EPOCHS ).batch (self .BATCH_SIZE ).shuffle (self .SHUFFLE_BUFFER )).next ())
158
+ self .sample_batch = tf .nest .map_structure (lambda x : x .numpy (), iter (dataset .repeat (self .NUM_EPOCHS ).batch (self .BATCH_SIZE ).shuffle (60000 , seed = self .SHUFFLE_SEED , reshuffle_each_iteration = True )).next ())
159
159
160
160
return (x_train , y_train )
161
161
@@ -180,7 +180,7 @@ def train(self, test, batch, schema_num):
180
180
181
181
# preprocess test dataset
182
182
testset = tf .data .Dataset .from_tensor_slices ((x_test , y_test ))
183
- processed_testset = testset .batch (self .BATCH_SIZE ).shuffle (self .SHUFFLE_BUFFER )
183
+ processed_testset = testset .batch (self .BATCH_SIZE ).shuffle (60000 , seed = self .SHUFFLE_SEED , reshuffle_each_iteration = True )
184
184
model = self .create_compiled_keras_model ()
185
185
186
186
# print(model.count_params())
0 commit comments