comparison deep/stacked_dae/aistats_review/m_mlp_ift.py @ 617:820764689d2f

Experiment to test the performance of shallower networks.
author Salah Rifai <salahmeister@gmail.com>
date Sun, 09 Jan 2011 12:45:44 -0500
parents
children
comparison
equal deleted inserted replaced
616:b0cdd200b2bd 617:820764689d2f
1 import pdb,bricks.costs,datetime,os,theano,sys
2 from bricks.experiments import *
3 from bricks.networks import *
4 from bricks import *
5 from datasets import *
6 from bricks.optimizer import *
7 from monitor.exp_monitoring import *
8
9 #from monitor.series import *
10 import numpy
11 #import jobman,jobman.sql,pylearn.version
12 #from jobman import DD
13 #from utils.JobmanHandling import *
14
15 class MnistTSdaeExperiment(ExperimentObject):
16 # Todo : Write down the interface
17
18 def _init_dataset(self):
19 self.dataset_list = [ PNIST07(), nist_all() ]
20 self.dataset = self.dataset_list[0]
21
22
23 def _init_outputs(self):
24 self.ds_output = { 'Pnist_Train' : self.dataset_list[0].train,
25 'Pnist_Valid' : self.dataset_list[0].valid,
26 'Pnist_Test' : self.dataset_list[0].test,
27 'nist_Train' : self.dataset_list[1].train,
28 'nist_Valid' : self.dataset_list[1].valid,
29 'nist_Test' : self.dataset_list[1].test}
30
31 self.outputs = { 'CC' : costs.classification_error(self.network.layers[-1][0].out_dict['argmax_softmax_output'],self.network.in_dict['pred']) }
32 #'L1' : costs.L1(self.network.layers[0][0].out_dict['sigmoid_output']) }
33 #'LL' : costs.negative_ll(self.network.layers[-1][0].out_dict['softmax_output'],self.network.in_dict['pred']) }
34
35
36
37 def _init_network(self):
38 """ Choose wich network to initialize """
39 #x,y = self.dataset.train(1).next()
40 n_i = 1024
41 n_o = 62
42 numpy.random.seed(self.hp['seed'])
43 self.network = MLPNetwork(n_i,n_o,size=self.hp['size'])
44 default.load_pickled_network(self.network,'best_params/1/')
45
46 def _init_costs_params(self):
47 #finetuning
48 self.costs = [ [costs.negative_ll(self.network.layers[-1][0].out_dict['softmax_output'],self.network.in_dict['pred'])] ]
49 self.params = [ [self.network.get_all_params(),self.network.get_all_params()] ]
50
51
52 def _init_monitor(self):
53 self.monitor = monitor(self.outputs,self.ds_output,self.network,self.sub_paths,save_criterion='Pnist_Valid')
54
55 def startexp(self):
56 print self.info()
57 for j,optimizer in enumerate(self.optimizers):
58 print 'Optim', '#'+str(j+1)
59 sys.stdout.flush()
60 for i in range(self.hp['ft_ep']):
61 optimizer.tune(self.dataset.train,self.hp['bs'])
62 print repr(i).rjust(3),self.monitor.get_str_output()
63 sys.stdout.flush()
64
65
66 def run(self):
67 self.startexp()
68 self.monitor.dump()
69 return True
70
71 def jobman_entrypoint(state, channel):
72 import jobman,jobman.sql,pylearn.version
73 from jobman import DD
74 from utils.JobmanHandling import JobHandling,jobman_insert,cartesian_product_jobs
75 exp = MnistTSdaeExperiment(state,channel)
76 return exp.jobhandler.start(state,channel)
77
78 def standalone(state):
79 exp = MnistTSdaeExperiment(state)
80 exp.run()
81
82
83 if __name__ == '__main__':
84 HP = { 'lr':[ [ .1] ],
85 'ft_ep':[100],
86 'bs':[100],
87 'size':[ [300],[4000],[5000],[6000],[7000] ],
88 'seed':[0]}
89
90 job_db_path = 'postgres://mullerx:b9f6ed1ee4@gershwin/mullerx_db/m_mlp_ift'
91 exp_path = "m_mlp_ift.jobman_entrypoint"
92
93 args = sys.argv[1:]
94
95 if len(args) > 0 and args[0] == 'jobman_insert':
96 jobman_insert(HP,job_db_path,exp_path)
97
98 elif len(args) > 0 and args[0] == 'jobman_test':
99 chanmock = DD({'COMPLETE':0,'save':(lambda:None)})
100 dd_hp = cartesian_product_jobs(HP)
101 print dd_hp[0]
102 jobman_entrypoint(dd_hp[0], chanmock)
103
104 elif len(args) > 0 and args[0] == 'standalone':
105 hp = { 'lr':[ .1],
106 'ft_ep':100,
107 'bs':100,
108 'size':[ 3000 ],
109 'seed':0}
110 standalone(hp)
111
112
113 else:
114 print "Bad arguments"
115
116
117 #jobman sqlview postgres://mullerx:b9f6ed1ee4@gershwin/mullerx_db/m_mlp_ift m_mlp_ift_view
118 #psql -h gershwin -U mullerx -d mullerx_db
119 #b9f6ed1ee4
120
121 #jobdispatch --condor --env=THEANO_FLAGS=floatX=float32 --repeat_jobs=5 jobman sql -n0 'postgres://mullerx:b9f6ed1ee4@gershwin/mullerx_db/m_mlp_ift' .