Mercurial > pylearn
comparison doc/v2_planning/plugin_RP_GD.py @ 1259:6f76ecef869e
a few changes
author | Razvan Pascanu <r.pascanu@gmail.com> |
---|---|
date | Fri, 24 Sep 2010 14:10:05 -0400 |
parents | c88db30f4e08 |
children |
comparison
equal
deleted
inserted
replaced
1258:c88db30f4e08 | 1259:6f76ecef869e |
---|---|
7 2. Components are then "wrapped" into **plugins** | 7 2. Components are then "wrapped" into **plugins** |
8 3. Plugins are registered through a **scheduler** to act on certain **events** | 8 3. Plugins are registered through a **scheduler** to act on certain **events** |
9 4. We have defined two basic types of events: | 9 4. We have defined two basic types of events: |
10 4.1 scheduler events: these are emitted by the scheduler itself. For now we have defined: | 10 4.1 scheduler events: these are emitted by the scheduler itself. For now we have defined: |
11 scheduler.begin() : sent at the very beginning of scheduler execution | 11 scheduler.begin() : sent at the very beginning of scheduler execution |
12 scheduler.end() : sent when the scheduler ends | 12 scheduler.end() : sent when the scheduler ends ( this makes sense since there is |
13 at least from the user perspective a hierarchy of schedulars) | |
13 4.2 plugin generate events: plugins act as iterators and generate 2 basic events, | 14 4.2 plugin generate events: plugins act as iterators and generate 2 basic events, |
14 plugin.next() : sent of every "iteration". Each plugin is free to define what an | 15 plugin.next() : sent of every "iteration". Each plugin is free to define what an |
15 iteration actually means. | 16 iteration actually means. |
16 plugin.end() : sent when the plugin is done iterating. | 17 plugin.end() : sent when the plugin is done iterating. |
17 5. Using Olivier Breuleux's schedular, plugins can decide to act on every event, every n-th | 18 5. Using Olivier Breuleux's schedular, plugins can decide to act on every event, every n-th |
29 """ | 30 """ |
30 This is an example of a plugin which takes care of counting "stuff". It is generic enough | 31 This is an example of a plugin which takes care of counting "stuff". It is generic enough |
31 that it would probably be included in the library somewhere. | 32 that it would probably be included in the library somewhere. |
32 """ | 33 """ |
33 | 34 |
34 def __init__(self, name, next_count, end_count): | 35 def __init__(self, name, end_count, next_count = 1): |
35 """ | 36 """ |
36 :param name: name of the event we are counting (could be useful for debugging) | 37 :param name: name of the event we are counting (could be useful for debugging) |
37 :param next_count: number of iterations before triggering a "next" event | 38 :param next_count: number of iterations before triggering a "next" event |
38 :param end_count: number of iterations before triggering an "end" event | 39 :param end_count: number of iterations before triggering an "end" event |
39 """ | 40 """ |
61 they themselves contain other plugins and their own schedulers. A meta-plugin would replace | 62 they themselves contain other plugins and their own schedulers. A meta-plugin would replace |
62 code-blocks which are usually found inside for-loop or if-else statements. | 63 code-blocks which are usually found inside for-loop or if-else statements. |
63 | 64 |
64 The fixed_epoch_trainer meta-plugin takes care of training a given model, for a fixed | 65 The fixed_epoch_trainer meta-plugin takes care of training a given model, for a fixed |
65 number of epochs and then saving the resulting model. | 66 number of epochs and then saving the resulting model. |
67 | |
68 Other arguments for having meta-plugin : | |
69 * they can define a semantically separable block of code | |
70 * they are what the library provides 99% of the code ( so you can define a certain | |
71 template of connecting plugins as a meta-plugin and ship it without worry of things) | |
72 * they can be breaked apart by the main schedular ( so you would not have "different" | |
73 schedulars running in the same time; is just one schedular, this way of constructing | |
74 things is just to improve understanding and intuitions of the syste | |
75 * they help pushing all the complexity over the backbone of the library ( i.e. the | |
76 schedular ) | |
77 * all plugins registered inside a hyper-plugin are active only when the hyper-plugin is | |
78 active; In this sense they can help definining scopes ( as for variables ) - optional | |
66 """ | 79 """ |
67 # we start by defining our own private scheduler | 80 # we start by defining our own private scheduler |
68 sched = Scheduler() | 81 sched = Scheduler() |
69 | 82 |
70 # convert "components" to plugins. Maybe this could be automated or done in another way... | 83 # convert "components" to plugins. Maybe this could be automated or done in another way... |