comparison deep/stacked_dae/utils.py @ 207:43af74a348ac

Merge branches from main repo.
author Arnaud Bergeron <abergeron@gmail.com>
date Thu, 04 Mar 2010 20:43:21 -0500
parents e656edaedb48
children 7b4507295eba
comparison
equal deleted inserted replaced
206:e12702b88a2d 207:43af74a348ac
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # coding: utf-8
3
4 from __future__ import with_statement
2 5
3 from jobman import DD 6 from jobman import DD
4 7
5 # from pylearn codebase 8 # from pylearn codebase
9 # useful in __init__(param1, param2, etc.) to save
10 # values in self.param1, self.param2... just call
11 # update_locals(self, locals())
6 def update_locals(obj, dct): 12 def update_locals(obj, dct):
7 if 'self' in dct: 13 if 'self' in dct:
8 del dct['self'] 14 del dct['self']
9 obj.__dict__.update(dct) 15 obj.__dict__.update(dct)
10 16
11 def produit_croise_jobs(val_dict): 17 # from a dictionary of possible values for hyperparameters, e.g.
18 # hp_values = {'learning_rate':[0.1, 0.01], 'num_layers': [1,2]}
19 # create a list of other dictionaries representing all the possible
20 # combinations, thus in this example creating:
21 # [{'learning_rate': 0.1, 'num_layers': 1}, ...]
22 # (similarly for combinations (0.1, 2), (0.01, 1), (0.01, 2))
23 def produit_cartesien_jobs(val_dict):
12 job_list = [DD()] 24 job_list = [DD()]
13 all_keys = val_dict.keys() 25 all_keys = val_dict.keys()
14 26
15 for key in all_keys: 27 for key in all_keys:
16 possible_values = val_dict[key] 28 possible_values = val_dict[key]
22 new_job_list.append(to_insert) 34 new_job_list.append(to_insert)
23 job_list = new_job_list 35 job_list = new_job_list
24 36
25 return job_list 37 return job_list
26 38
27 def test_produit_croise_jobs(): 39 def test_produit_cartesien_jobs():
28 vals = {'a': [1,2], 'b': [3,4,5]} 40 vals = {'a': [1,2], 'b': [3,4,5]}
29 print produit_croise_jobs(vals) 41 print produit_cartesien_jobs(vals)
30 42
31 43
32 # taken from http://stackoverflow.com/questions/276052/how-to-get-current-cpu-and-ram-usage-in-python 44 # taken from http://stackoverflow.com/questions/276052/how-to-get-current-cpu-and-ram-usage-in-python
33 """Simple module for getting amount of memory used by a specified user's 45 """Simple module for getting amount of memory used by a specified user's
34 processes on a UNIX system. 46 processes on a UNIX system.