annotate doc/v2_planning/plugin_RP_GD.py @ 1258:c88db30f4e08

added comments to our plugin proposal
author gdesjardins
date Fri, 24 Sep 2010 13:59:47 -0400
parents bf41991692ea
children 6f76ecef869e
rev   line source
1258
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
1 """
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
2 BASIC IDEA
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
3 ==========
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
4
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
5 The main ideas of the proposal are as follows:
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
6 1. Basic components are defined in the traditional way (classes, methods, etc.)
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
7 2. Components are then "wrapped" into **plugins**
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
8 3. Plugins are registered through a **scheduler** to act on certain **events**
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
9 4. We have defined two basic types of events:
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
10 4.1 scheduler events: these are emitted by the scheduler itself. For now we have defined:
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
11 scheduler.begin() : sent at the very beginning of scheduler execution
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
12 scheduler.end() : sent when the scheduler ends
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
13 4.2 plugin generate events: plugins act as iterators and generate 2 basic events,
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
14 plugin.next() : sent of every "iteration". Each plugin is free to define what an
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
15 iteration actually means.
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
16 plugin.end() : sent when the plugin is done iterating.
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
17 5. Using Olivier Breuleux's schedular, plugins can decide to act on every event, every n-th
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
18 occurence of an event, etc.
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
19
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
20 OVERVIEW
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
21 ========
1256
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
22
1258
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
23 The code below attempts to show how one would code a training experiment, where we pre-train +
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
24 fine-tune a DBN, while using cross-validation. We have ommitted data preprocessing for now, but
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
25 do not think it would have much of an impact on the finished product.
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
26 """
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
27
1256
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
28 class Counter(Plugin):
1258
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
29 """
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
30 This is an example of a plugin which takes care of counting "stuff". It is generic enough
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
31 that it would probably be included in the library somewhere.
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
32 """
1256
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
33
1258
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
34 def __init__(self, name, next_count, end_count):
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
35 """
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
36 :param name: name of the event we are counting (could be useful for debugging)
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
37 :param next_count: number of iterations before triggering a "next" event
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
38 :param end_count: number of iterations before triggering an "end" event
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
39 """
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
40 super(self, Counter).__init__()
1256
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
41 self.n = 0
1258
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
42 self.next_count = next_count
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
43 self.end_count = end_count
1256
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
44
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
45 def execute(self, msg):
1258
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
46 """
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
47 The execute function is the one which gets executed each time the plugin is "acted"
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
48 upon. This will send "next" and "end" events to the scheduler, which other plugins can
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
49 listen to. We show an example of this later.
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
50 """
1256
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
51 self.n += 1
1258
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
52 if self.n > self.end_count:
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
53 self.fire(Event('end', value = self.n))
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
54 elif self.n > self.next_count:
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
55 self.fire(Event('next', value = self.n))
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
56
1256
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
57
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
58 def fixed_epoch_trainer(model, save, n_epochs):
1258
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
59 """
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
60 This is an example of a meta-plugin. Meta-plugin are just like any other plugins, except
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
61 they themselves contain other plugins and their own schedulers. A meta-plugin would replace
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
62 code-blocks which are usually found inside for-loop or if-else statements.
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
63
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
64 The fixed_epoch_trainer meta-plugin takes care of training a given model, for a fixed
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
65 number of epochs and then saving the resulting model.
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
66 """
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
67 # we start by defining our own private scheduler
1256
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
68 sched = Scheduler()
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
69
1258
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
70 # convert "components" to plugins. Maybe this could be automated or done in another way...
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
71 # syntax is not really important here.
1256
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
72 [model, validate, save] = map(pluggin_wrapper, [model, validate, save])
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
73
1258
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
74 # instantiate the counter plugin to "end" after n_epochs
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
75 counter = Counter('epoch', 1, n_epochs)
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
76
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
77 ####
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
78 # Registering actions: overview of syntax
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
79 # plugin1.act(sched, on=[event1, event2]) means that that plugin1 will perform one
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
80 # "iteration" on every occurence of event1 and event2.
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
81 ####
1256
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
82
1258
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
83 # In our example, we assume that 1 iteration of "model" means 1 minibatch update.
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
84 # Model performs an iteration:
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
85 # * when program first starts
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
86 # * after is it done with previous iteration (auto-loop)
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
87 # * after each epoch, as defined by the counter. The counter counts epochs by "trapping"
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
88 # the model's end event.
1256
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
89 model.act(sched, on=[sched.begin(), model.step(), counter.step()])
1258
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
90 # counter is incremented every time the
1256
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
91 counter.act(sched, on=model.end())
1258
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
92 # the save_model plugin then takes care of saving everything once the counter expires
1256
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
93 save_model.act(sched, on=counter.end())
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
94
1258
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
95 # Meta-plugins also generate events: they map "internal" events to "external" events
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
96 # fixed_epoch_trainer.end() will thus correspond to counter.end()
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
97 sched.end(on=counter.end())
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
98 # in the same way, you could have:
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
99 # sched.next(on=counter.next()) but this is not useful here
1256
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
100
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
101 return sched
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
102
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
103 def early_stop_trainer(model, validate, save, **kw):
1258
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
104 """
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
105 This is another plugin example, which takes care of training the model but using early
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
106 stopping.
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
107 """
1256
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
108 sched = Scheduler()
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
109
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
110 # define plugins
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
111 [model, validate, save] = map(pluggin_wrapper, [model, validate, save])
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
112
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
113 early_stop = Stopper(**kw)
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
114
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
115 # register actions
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
116 model.act(sched, on=[sched.begin(), model.step(), validate.step()])
1258
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
117 # we measure validation error after every epoch (model.end)
1256
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
118 validate.act(sched, on=model.end())
1258
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
119 # early-stopper gets triggered every time we have a new validation error
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
120 # the error itself is passed within the "step" message
1256
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
121 early_stop.act(sched, on=validate.step())
1258
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
122 # model is saved whenever we find a new best model (early_stop.step) or when we have found
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
123 # THE best model (early_stop.end)
1256
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
124 save_model.act(sched, on=[early_stop.step(), early_stop.end()])
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
125
1258
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
126 sched.end(on=early_stop.end())
1256
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
127
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
128 return sched
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
129
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
130 def dbn_trainer(rbm1, rbm2):
1258
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
131 """
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
132 This meta-plugin pre-trains a two-layer DBN for a fixed number of epochs, and then performs
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
133 fine-tuning on the resulting MLP. This should hopefully be self-explanatory.
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
134 """
1256
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
135 sched = Scheduler()
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
136
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
137 pretrain_layer1 = fixed_epoch_trainer(rbm1, save)
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
138 pretrain_layer1.act(sched, on=sched.begin())
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
139
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
140 pretrain_layer2 = fixed_epoch_trainer(rbm2, save)
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
141 pretrain_layer2.act(sched, on=pretrain_layer1.end())
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
142
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
143 ## TBD: by the layer committee
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
144 mlp = function(rbm1, rbm2)
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
145
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
146 fine_tuning = early_stop_trainer(mlp, validate_mlp, save_mlp)
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
147 fine_tuning.act(sched, on=pretrain_layer2.end())
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
148
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
149 return sched
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
150
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
151 def single_crossval_run(trainer, kfold_plugin, kfold_measure)
1258
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
152 """
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
153 For a fixed set of hyper-parameters, this evaluates the generalization error using KFold
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
154 cross-validation.
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
155 """
1256
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
156
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
157 sched = Scheduler()
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
158
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
159 # k-fold plugin will call rbm.change_dataset using various splits of the data
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
160 kfold_plugin.act(sched, on=[sched.begin(), trainer.end()])
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
161 trainer.act(sched, on=[kfold_plugin.step()])
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
162
1258
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
163 # trainer ends on early_stop.end(). This means that trainer.end() will forward
1256
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
164 # the early-stopping message which contains the best validation error.
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
165 kfold_measure.act(sched, on=[trainer.end(), kill=kfold_plugin.end()]
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
166
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
167 # this best validation error is then forwarded by single_crossval_run
1258
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
168 sched.end(on=kfold_measure.end())
1256
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
169
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
170 return sched
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
171
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
172
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
173 #### MAIN LOOP ####
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
174 rbm1 = ...
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
175 rbm2 = ...
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
176 dataset = ....
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
177 dbn_trainer = dbn_trainer(rbm1, rbm2)
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
178 kfold_plugin = KFold([rbm1, rbm2], dataset)
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
179 kfold_measure = ...
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
180
1258
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
181 ## In our view, the meta-plugins defined above would live in the library somewhere. Hooks can be
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
182 ## added without modifying the library code. The meta-plugin's scheduler contains a dictionary
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
183 ## of "registered" plugins along with their events. We can thus register "user-plugins" based on
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
184 ## any of these events.
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
185 # define a logger plugin of some sort
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
186 print_stat = ....
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
187 # act on each iteration of the early-stopping plugin
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
188 # NB: the message is forwarded as is. It is up to the print_stat plugin to parse it properly.
1256
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
189 print_stat.act(pretrain_layer1, on=pretrain_layer1.plugins['early_stop'].step())
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
190
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
191 #### THIS SHOULD CORRESPOND TO THE OUTER LOOP ####
1258
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
192 # this is the final outer-loop which tests various configurations of hyperparameters
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
193
1256
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
194 sched = Scheduler()
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
195
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
196 hyperparam_change = DBN_HyperParam([rbm1, rbm2])
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
197 hyperparam_test = single_crossval_run(dbn_trainer, kfold_plugin, kfold_measure)
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
198
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
199 hyperparam_change.act(sched, on=[sched.begin(), hyperparam_test.end()])
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
200 hyperparam_test.act(sched, on=hyperparam_change.step())
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
201
1258
c88db30f4e08 added comments to our plugin proposal
gdesjardins
parents: 1256
diff changeset
202 sched.end(hyperparam_change.end())
1256
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
203
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
204 ##### RUN THE WHOLE DAMN THING #####
bf41991692ea new plugin approach
gdesjardins
parents:
diff changeset
205 sched.run()