diff --git a/helperfns.py b/helperfns.py index a5b2e1f..16af28d 100644 --- a/helperfns.py +++ b/helperfns.py @@ -342,6 +342,10 @@ def set_defaults(params): params['d'] = len(params['widths']) # d must be calculated like this # defaults related to initialization of parameters + if 'seed' not in params: + random_seed = np.random.randint(2 ** 30) + print("setting default: choosing random seed of %d and saving to params" % random_seed) + params['seed'] = random_seed if 'dist_weights' not in params: print("setting default: distribution for weights on main net is tn (truncated normal)") params['dist_weights'] = 'tn' diff --git a/training.py b/training.py index a7a236b..3fe6131 100644 --- a/training.py +++ b/training.py @@ -304,6 +304,8 @@ def main_exp(params): if not os.path.exists(params['folder_name']): os.makedirs(params['folder_name']) + tf.set_random_seed(params['seed']) + np.random.seed(params['seed']) # data is num_steps x num_examples x n but load flattened version (matrix instead of tensor) data_val = np.loadtxt(('./data/%s_val_x.csv' % (params['data_name'])), delimiter=',', dtype=np.float64) try_net(data_val, params)