Mercurial > ift6266
annotate deep/convolutional_dae/run_exp.py @ 292:8108d271c30c
Fix stuff (imports, ...) so that it can run under jobman properly.
author | Arnaud Bergeron <abergeron@gmail.com> |
---|---|
date | Fri, 26 Mar 2010 18:49:27 -0400 |
parents | 7d1fa2d7721c |
children | d89820070ea0 |
rev | line source |
---|---|
291
7d1fa2d7721c
Split out the run_exp method.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff
changeset
|
1 from ift6266.deep.convolutional_dae.scdae import * |
7d1fa2d7721c
Split out the run_exp method.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff
changeset
|
2 |
7d1fa2d7721c
Split out the run_exp method.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff
changeset
|
3 class dumb(object): |
7d1fa2d7721c
Split out the run_exp method.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff
changeset
|
4 def save(self): |
7d1fa2d7721c
Split out the run_exp method.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff
changeset
|
5 pass |
7d1fa2d7721c
Split out the run_exp method.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff
changeset
|
6 |
7d1fa2d7721c
Split out the run_exp method.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff
changeset
|
7 def go(state, channel): |
7d1fa2d7721c
Split out the run_exp method.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff
changeset
|
8 from ift6266 import datasets |
7d1fa2d7721c
Split out the run_exp method.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff
changeset
|
9 from ift6266.deep.convolutional_dae.sgd_opt import sgd_opt |
7d1fa2d7721c
Split out the run_exp method.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff
changeset
|
10 import pylearn, theano, ift6266 |
7d1fa2d7721c
Split out the run_exp method.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff
changeset
|
11 import pylearn.version |
7d1fa2d7721c
Split out the run_exp method.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff
changeset
|
12 |
7d1fa2d7721c
Split out the run_exp method.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff
changeset
|
13 # params: bsize, pretrain_lr, train_lr, nfilts1, nfilts2, nftils3, nfilts4 |
7d1fa2d7721c
Split out the run_exp method.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff
changeset
|
14 # pretrain_rounds, noise, mlp_sz |
7d1fa2d7721c
Split out the run_exp method.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff
changeset
|
15 |
7d1fa2d7721c
Split out the run_exp method.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff
changeset
|
16 pylearn.version.record_versions(state, [theano, ift6266, pylearn]) |
7d1fa2d7721c
Split out the run_exp method.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff
changeset
|
17 # TODO: maybe record pynnet version? |
7d1fa2d7721c
Split out the run_exp method.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff
changeset
|
18 channel.save() |
7d1fa2d7721c
Split out the run_exp method.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff
changeset
|
19 |
7d1fa2d7721c
Split out the run_exp method.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff
changeset
|
20 dset = datasets.nist_all(1000) |
7d1fa2d7721c
Split out the run_exp method.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff
changeset
|
21 |
7d1fa2d7721c
Split out the run_exp method.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff
changeset
|
22 nfilts = [] |
7d1fa2d7721c
Split out the run_exp method.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff
changeset
|
23 if state.nfilts1 != 0: |
7d1fa2d7721c
Split out the run_exp method.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff
changeset
|
24 nfilts.append(state.nfilts1) |
7d1fa2d7721c
Split out the run_exp method.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff
changeset
|
25 if state.nfilts2 != 0: |
7d1fa2d7721c
Split out the run_exp method.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff
changeset
|
26 nfilts.append(state.nfilts2) |
7d1fa2d7721c
Split out the run_exp method.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff
changeset
|
27 if state.nfilts3 != 0: |
7d1fa2d7721c
Split out the run_exp method.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff
changeset
|
28 nfilts.append(state.nfilts3) |
7d1fa2d7721c
Split out the run_exp method.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff
changeset
|
29 if state.nfilts4 != 0: |
7d1fa2d7721c
Split out the run_exp method.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff
changeset
|
30 nfilts.append(state.nfilts4) |
7d1fa2d7721c
Split out the run_exp method.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff
changeset
|
31 |
7d1fa2d7721c
Split out the run_exp method.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff
changeset
|
32 fsizes = [(5,5)]*len(nfilts) |
7d1fa2d7721c
Split out the run_exp method.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff
changeset
|
33 subs = [(2,2)]*len(nfilts) |
7d1fa2d7721c
Split out the run_exp method.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff
changeset
|
34 noise = [state.noise]*len(nfilts) |
7d1fa2d7721c
Split out the run_exp method.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff
changeset
|
35 |
7d1fa2d7721c
Split out the run_exp method.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff
changeset
|
36 pretrain_funcs, trainf, evalf, net = build_funcs( |
7d1fa2d7721c
Split out the run_exp method.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff
changeset
|
37 img_size=(32, 32), |
7d1fa2d7721c
Split out the run_exp method.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff
changeset
|
38 batch_size=state.bsize, |
7d1fa2d7721c
Split out the run_exp method.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff
changeset
|
39 filter_sizes=fsizes, |
7d1fa2d7721c
Split out the run_exp method.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff
changeset
|
40 num_filters=nfilts, |
7d1fa2d7721c
Split out the run_exp method.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff
changeset
|
41 subs=subs, |
7d1fa2d7721c
Split out the run_exp method.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff
changeset
|
42 noise=noise, |
7d1fa2d7721c
Split out the run_exp method.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff
changeset
|
43 mlp_sizes=[state.mlp_sz], |
7d1fa2d7721c
Split out the run_exp method.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff
changeset
|
44 out_size=62, |
7d1fa2d7721c
Split out the run_exp method.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff
changeset
|
45 dtype=numpy.float32, |
7d1fa2d7721c
Split out the run_exp method.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff
changeset
|
46 pretrain_lr=state.pretrain_lr, |
7d1fa2d7721c
Split out the run_exp method.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff
changeset
|
47 train_lr=state.train_lr) |
7d1fa2d7721c
Split out the run_exp method.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff
changeset
|
48 |
7d1fa2d7721c
Split out the run_exp method.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff
changeset
|
49 pretrain_fs, train, valid, test = massage_funcs( |
292
8108d271c30c
Fix stuff (imports, ...) so that it can run under jobman properly.
Arnaud Bergeron <abergeron@gmail.com>
parents:
291
diff
changeset
|
50 repeat_itf(dset.train, state.bsize), |
8108d271c30c
Fix stuff (imports, ...) so that it can run under jobman properly.
Arnaud Bergeron <abergeron@gmail.com>
parents:
291
diff
changeset
|
51 dset, state.bsize, |
8108d271c30c
Fix stuff (imports, ...) so that it can run under jobman properly.
Arnaud Bergeron <abergeron@gmail.com>
parents:
291
diff
changeset
|
52 pretrain_funcs, trainf,evalf) |
291
7d1fa2d7721c
Split out the run_exp method.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff
changeset
|
53 |
7d1fa2d7721c
Split out the run_exp method.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff
changeset
|
54 series = create_series() |
7d1fa2d7721c
Split out the run_exp method.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff
changeset
|
55 |
7d1fa2d7721c
Split out the run_exp method.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff
changeset
|
56 do_pretrain(pretrain_fs, state.pretrain_rounds, series['recons_error']) |
7d1fa2d7721c
Split out the run_exp method.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff
changeset
|
57 |
7d1fa2d7721c
Split out the run_exp method.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff
changeset
|
58 sgd_opt(train, valid, test, training_epochs=100000, patience=10000, |
7d1fa2d7721c
Split out the run_exp method.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff
changeset
|
59 patience_increase=2., improvement_threshold=0.995, |
7d1fa2d7721c
Split out the run_exp method.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff
changeset
|
60 validation_frequency=2500, series=series, net=net) |
7d1fa2d7721c
Split out the run_exp method.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff
changeset
|
61 |
7d1fa2d7721c
Split out the run_exp method.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff
changeset
|
62 if __name__ == '__main__': |
7d1fa2d7721c
Split out the run_exp method.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff
changeset
|
63 st = dumb() |
7d1fa2d7721c
Split out the run_exp method.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff
changeset
|
64 st.bsize = 100 |
7d1fa2d7721c
Split out the run_exp method.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff
changeset
|
65 st.pretrain_lr = 0.01 |
7d1fa2d7721c
Split out the run_exp method.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff
changeset
|
66 st.train_lr = 0.1 |
7d1fa2d7721c
Split out the run_exp method.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff
changeset
|
67 st.nfilts1 = 4 |
7d1fa2d7721c
Split out the run_exp method.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff
changeset
|
68 st.nfilts2 = 4 |
7d1fa2d7721c
Split out the run_exp method.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff
changeset
|
69 st.nfilts3 = 0 |
7d1fa2d7721c
Split out the run_exp method.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff
changeset
|
70 st.pretrain_rounds = 500 |
7d1fa2d7721c
Split out the run_exp method.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff
changeset
|
71 st.noise=0.2 |
7d1fa2d7721c
Split out the run_exp method.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff
changeset
|
72 st.mlp_sz = 500 |
7d1fa2d7721c
Split out the run_exp method.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff
changeset
|
73 go(st, dumb()) |