Mercurial > pylearn
annotate learner.py @ 379:74b402b5a81b
small modif by yoshue
author | Frederic Bastien <bastienf@iro.umontreal.ca> |
---|---|
date | Mon, 07 Jul 2008 12:27:06 -0400 |
parents | fe57b96f33d4 |
children |
rev | line source |
---|---|
211
bd728c83faff
in __get__, problem if the i.stop was None, i being the slice, added one line replacing None by the len(self)
Thierry Bertin-Mahieux <bertinmt@iro.umontreal.ca>
parents:
209
diff
changeset
|
1 |
1
2cd82666b9a7
Added statscollector and started writing dataset and learner.
bengioy@esprit.iro.umontreal.ca
parents:
0
diff
changeset
|
2 |
172
fb4837eed1a6
fixed import of AbstractFunction
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
167
diff
changeset
|
3 from exceptions import * |
209
50a8302addaf
template statscollector
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
193
diff
changeset
|
4 from dataset import AttributesHolder |
180
2698c0feeb54
mlp seems to work!
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
177
diff
changeset
|
5 |
262
14b9779622f9
Split LearningAlgorithm into OfflineLearningAlgorithm and OnlineLearningAlgorithm
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
211
diff
changeset
|
6 class OfflineLearningAlgorithm(object): |
132
f6505ec32dc3
Updated documentation slightly
Joseph Turian <turian@gmail.com>
parents:
131
diff
changeset
|
7 """ |
262
14b9779622f9
Split LearningAlgorithm into OfflineLearningAlgorithm and OnlineLearningAlgorithm
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
211
diff
changeset
|
8 Base class for offline learning algorithms, provides an interface |
1
2cd82666b9a7
Added statscollector and started writing dataset and learner.
bengioy@esprit.iro.umontreal.ca
parents:
0
diff
changeset
|
9 that allows various algorithms to be applicable to generic learning |
193
cb6b945acf5a
Complete redesign of learner...
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
180
diff
changeset
|
10 algorithms. It is only given here to define the expected semantics. |
1
2cd82666b9a7
Added statscollector and started writing dataset and learner.
bengioy@esprit.iro.umontreal.ca
parents:
0
diff
changeset
|
11 |
262
14b9779622f9
Split LearningAlgorithm into OfflineLearningAlgorithm and OnlineLearningAlgorithm
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
211
diff
changeset
|
12 An offline learning algorithm can be seen as a function that when |
135
0d8e721cc63c
Fixed bugs in dataset to make test_mlp.py work
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
134
diff
changeset
|
13 applied to training data returns a learned function (which is an object that |
0d8e721cc63c
Fixed bugs in dataset to make test_mlp.py work
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
134
diff
changeset
|
14 can be applied to other data and return some output data). |
193
cb6b945acf5a
Complete redesign of learner...
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
180
diff
changeset
|
15 |
262
14b9779622f9
Split LearningAlgorithm into OfflineLearningAlgorithm and OnlineLearningAlgorithm
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
211
diff
changeset
|
16 The offline learning scenario is the standard and most common one |
14b9779622f9
Split LearningAlgorithm into OfflineLearningAlgorithm and OnlineLearningAlgorithm
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
211
diff
changeset
|
17 in machine learning: an offline learning algorithm is applied |
193
cb6b945acf5a
Complete redesign of learner...
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
180
diff
changeset
|
18 to a training dataset, |
cb6b945acf5a
Complete redesign of learner...
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
180
diff
changeset
|
19 |
326
fe57b96f33d4
made ExampleWiseMean Op
Olivier Breuleux <breuleuo@iro.umontreal.ca>
parents:
287
diff
changeset
|
20 model = learning_algorithm(training_set) |
193
cb6b945acf5a
Complete redesign of learner...
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
180
diff
changeset
|
21 |
262
14b9779622f9
Split LearningAlgorithm into OfflineLearningAlgorithm and OnlineLearningAlgorithm
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
211
diff
changeset
|
22 resulting in a fully trained model that can be applied to another dataset |
14b9779622f9
Split LearningAlgorithm into OfflineLearningAlgorithm and OnlineLearningAlgorithm
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
211
diff
changeset
|
23 in order to perform some desired computation: |
193
cb6b945acf5a
Complete redesign of learner...
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
180
diff
changeset
|
24 |
cb6b945acf5a
Complete redesign of learner...
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
180
diff
changeset
|
25 output_dataset = model(input_dataset) |
cb6b945acf5a
Complete redesign of learner...
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
180
diff
changeset
|
26 |
cb6b945acf5a
Complete redesign of learner...
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
180
diff
changeset
|
27 Note that the application of a dataset has no side-effect on the model. |
cb6b945acf5a
Complete redesign of learner...
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
180
diff
changeset
|
28 In that example, the training set may for example have 'input' and 'target' |
cb6b945acf5a
Complete redesign of learner...
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
180
diff
changeset
|
29 fields while the input dataset may have only 'input' (or both 'input' and |
cb6b945acf5a
Complete redesign of learner...
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
180
diff
changeset
|
30 'target') and the output dataset would contain some default output fields defined |
262
14b9779622f9
Split LearningAlgorithm into OfflineLearningAlgorithm and OnlineLearningAlgorithm
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
211
diff
changeset
|
31 by the learning algorithm (e.g. 'output' and 'error'). The user may specifiy |
14b9779622f9
Split LearningAlgorithm into OfflineLearningAlgorithm and OnlineLearningAlgorithm
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
211
diff
changeset
|
32 what the output dataset should contain either by setting options in the |
14b9779622f9
Split LearningAlgorithm into OfflineLearningAlgorithm and OnlineLearningAlgorithm
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
211
diff
changeset
|
33 model, by the presence of particular fields in the input dataset, or with |
14b9779622f9
Split LearningAlgorithm into OfflineLearningAlgorithm and OnlineLearningAlgorithm
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
211
diff
changeset
|
34 keyword options of the __call__ method of the model (see LearnedModel.__call__). |
14b9779622f9
Split LearningAlgorithm into OfflineLearningAlgorithm and OnlineLearningAlgorithm
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
211
diff
changeset
|
35 |
14b9779622f9
Split LearningAlgorithm into OfflineLearningAlgorithm and OnlineLearningAlgorithm
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
211
diff
changeset
|
36 """ |
14b9779622f9
Split LearningAlgorithm into OfflineLearningAlgorithm and OnlineLearningAlgorithm
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
211
diff
changeset
|
37 |
14b9779622f9
Split LearningAlgorithm into OfflineLearningAlgorithm and OnlineLearningAlgorithm
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
211
diff
changeset
|
38 def __init__(self): pass |
14b9779622f9
Split LearningAlgorithm into OfflineLearningAlgorithm and OnlineLearningAlgorithm
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
211
diff
changeset
|
39 |
14b9779622f9
Split LearningAlgorithm into OfflineLearningAlgorithm and OnlineLearningAlgorithm
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
211
diff
changeset
|
40 def __call__(self, training_dataset): |
14b9779622f9
Split LearningAlgorithm into OfflineLearningAlgorithm and OnlineLearningAlgorithm
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
211
diff
changeset
|
41 """ |
14b9779622f9
Split LearningAlgorithm into OfflineLearningAlgorithm and OnlineLearningAlgorithm
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
211
diff
changeset
|
42 Return a fully trained TrainedModel. |
14b9779622f9
Split LearningAlgorithm into OfflineLearningAlgorithm and OnlineLearningAlgorithm
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
211
diff
changeset
|
43 """ |
14b9779622f9
Split LearningAlgorithm into OfflineLearningAlgorithm and OnlineLearningAlgorithm
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
211
diff
changeset
|
44 raise AbstractFunction() |
14b9779622f9
Split LearningAlgorithm into OfflineLearningAlgorithm and OnlineLearningAlgorithm
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
211
diff
changeset
|
45 |
14b9779622f9
Split LearningAlgorithm into OfflineLearningAlgorithm and OnlineLearningAlgorithm
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
211
diff
changeset
|
46 class TrainedModel(AttributesHolder): |
14b9779622f9
Split LearningAlgorithm into OfflineLearningAlgorithm and OnlineLearningAlgorithm
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
211
diff
changeset
|
47 """ |
14b9779622f9
Split LearningAlgorithm into OfflineLearningAlgorithm and OnlineLearningAlgorithm
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
211
diff
changeset
|
48 TrainedModel is a base class for models returned by instances of an |
14b9779622f9
Split LearningAlgorithm into OfflineLearningAlgorithm and OnlineLearningAlgorithm
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
211
diff
changeset
|
49 OfflineLearningAlgorithm subclass. It is only given here to define the expected semantics. |
14b9779622f9
Split LearningAlgorithm into OfflineLearningAlgorithm and OnlineLearningAlgorithm
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
211
diff
changeset
|
50 """ |
14b9779622f9
Split LearningAlgorithm into OfflineLearningAlgorithm and OnlineLearningAlgorithm
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
211
diff
changeset
|
51 def __init__(self): |
14b9779622f9
Split LearningAlgorithm into OfflineLearningAlgorithm and OnlineLearningAlgorithm
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
211
diff
changeset
|
52 pass |
193
cb6b945acf5a
Complete redesign of learner...
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
180
diff
changeset
|
53 |
262
14b9779622f9
Split LearningAlgorithm into OfflineLearningAlgorithm and OnlineLearningAlgorithm
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
211
diff
changeset
|
54 def __call__(self,input_dataset,output_fieldnames=None, |
14b9779622f9
Split LearningAlgorithm into OfflineLearningAlgorithm and OnlineLearningAlgorithm
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
211
diff
changeset
|
55 test_stats_collector=None,copy_inputs=False, |
14b9779622f9
Split LearningAlgorithm into OfflineLearningAlgorithm and OnlineLearningAlgorithm
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
211
diff
changeset
|
56 put_stats_in_output_dataset=True, |
14b9779622f9
Split LearningAlgorithm into OfflineLearningAlgorithm and OnlineLearningAlgorithm
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
211
diff
changeset
|
57 output_attributes=[]): |
14b9779622f9
Split LearningAlgorithm into OfflineLearningAlgorithm and OnlineLearningAlgorithm
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
211
diff
changeset
|
58 """ |
14b9779622f9
Split LearningAlgorithm into OfflineLearningAlgorithm and OnlineLearningAlgorithm
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
211
diff
changeset
|
59 A L{TrainedModel} can be used with |
14b9779622f9
Split LearningAlgorithm into OfflineLearningAlgorithm and OnlineLearningAlgorithm
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
211
diff
changeset
|
60 with one or more calls to it. The main argument is an input L{DataSet} (possibly |
14b9779622f9
Split LearningAlgorithm into OfflineLearningAlgorithm and OnlineLearningAlgorithm
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
211
diff
changeset
|
61 containing a single example) and the result is an output L{DataSet} of the same length. |
14b9779622f9
Split LearningAlgorithm into OfflineLearningAlgorithm and OnlineLearningAlgorithm
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
211
diff
changeset
|
62 If output_fieldnames is specified, it may be use to indicate which fields should |
14b9779622f9
Split LearningAlgorithm into OfflineLearningAlgorithm and OnlineLearningAlgorithm
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
211
diff
changeset
|
63 be constructed in the output L{DataSet} (for example ['output','classification_error']). |
14b9779622f9
Split LearningAlgorithm into OfflineLearningAlgorithm and OnlineLearningAlgorithm
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
211
diff
changeset
|
64 Otherwise, some default output fields are produced (possibly depending on the input |
14b9779622f9
Split LearningAlgorithm into OfflineLearningAlgorithm and OnlineLearningAlgorithm
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
211
diff
changeset
|
65 fields available in the input_dataset). |
14b9779622f9
Split LearningAlgorithm into OfflineLearningAlgorithm and OnlineLearningAlgorithm
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
211
diff
changeset
|
66 Optionally, if copy_inputs, the input fields (of the input_dataset) can be made |
14b9779622f9
Split LearningAlgorithm into OfflineLearningAlgorithm and OnlineLearningAlgorithm
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
211
diff
changeset
|
67 visible in the output L{DataSet} returned by this method. |
14b9779622f9
Split LearningAlgorithm into OfflineLearningAlgorithm and OnlineLearningAlgorithm
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
211
diff
changeset
|
68 Optionally, attributes of the learner can be copied in the output dataset, |
14b9779622f9
Split LearningAlgorithm into OfflineLearningAlgorithm and OnlineLearningAlgorithm
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
211
diff
changeset
|
69 and statistics computed by the stats collector also put in the output dataset. |
14b9779622f9
Split LearningAlgorithm into OfflineLearningAlgorithm and OnlineLearningAlgorithm
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
211
diff
changeset
|
70 Note the distinction between fields (which are example-wise quantities, e.g. 'input') |
14b9779622f9
Split LearningAlgorithm into OfflineLearningAlgorithm and OnlineLearningAlgorithm
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
211
diff
changeset
|
71 and attributes (which are not, e.g. 'regularization_term'). |
14b9779622f9
Split LearningAlgorithm into OfflineLearningAlgorithm and OnlineLearningAlgorithm
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
211
diff
changeset
|
72 """ |
14b9779622f9
Split LearningAlgorithm into OfflineLearningAlgorithm and OnlineLearningAlgorithm
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
211
diff
changeset
|
73 raise AbstractFunction() |
14b9779622f9
Split LearningAlgorithm into OfflineLearningAlgorithm and OnlineLearningAlgorithm
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
211
diff
changeset
|
74 |
14b9779622f9
Split LearningAlgorithm into OfflineLearningAlgorithm and OnlineLearningAlgorithm
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
211
diff
changeset
|
75 |
14b9779622f9
Split LearningAlgorithm into OfflineLearningAlgorithm and OnlineLearningAlgorithm
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
211
diff
changeset
|
76 class OnlineLearningAlgorithm(object): |
14b9779622f9
Split LearningAlgorithm into OfflineLearningAlgorithm and OnlineLearningAlgorithm
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
211
diff
changeset
|
77 """ |
14b9779622f9
Split LearningAlgorithm into OfflineLearningAlgorithm and OnlineLearningAlgorithm
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
211
diff
changeset
|
78 Base class for online learning algorithms, provides an interface |
14b9779622f9
Split LearningAlgorithm into OfflineLearningAlgorithm and OnlineLearningAlgorithm
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
211
diff
changeset
|
79 that allows various algorithms to be applicable to generic online learning |
14b9779622f9
Split LearningAlgorithm into OfflineLearningAlgorithm and OnlineLearningAlgorithm
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
211
diff
changeset
|
80 algorithms. It is only given here to define the expected semantics. |
14b9779622f9
Split LearningAlgorithm into OfflineLearningAlgorithm and OnlineLearningAlgorithm
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
211
diff
changeset
|
81 |
14b9779622f9
Split LearningAlgorithm into OfflineLearningAlgorithm and OnlineLearningAlgorithm
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
211
diff
changeset
|
82 The basic setting is that the training data are only revealed in pieces |
193
cb6b945acf5a
Complete redesign of learner...
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
180
diff
changeset
|
83 (maybe one example or a batch of example at a time): |
cb6b945acf5a
Complete redesign of learner...
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
180
diff
changeset
|
84 |
cb6b945acf5a
Complete redesign of learner...
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
180
diff
changeset
|
85 model = learning_algorithm() |
cb6b945acf5a
Complete redesign of learner...
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
180
diff
changeset
|
86 |
cb6b945acf5a
Complete redesign of learner...
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
180
diff
changeset
|
87 results in a fresh model. The model can be adapted by presenting |
cb6b945acf5a
Complete redesign of learner...
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
180
diff
changeset
|
88 it with some training data, |
cb6b945acf5a
Complete redesign of learner...
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
180
diff
changeset
|
89 |
cb6b945acf5a
Complete redesign of learner...
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
180
diff
changeset
|
90 model.update(some_training_data) |
cb6b945acf5a
Complete redesign of learner...
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
180
diff
changeset
|
91 ... |
cb6b945acf5a
Complete redesign of learner...
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
180
diff
changeset
|
92 model.update(some_more_training_data) |
cb6b945acf5a
Complete redesign of learner...
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
180
diff
changeset
|
93 ... |
cb6b945acf5a
Complete redesign of learner...
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
180
diff
changeset
|
94 model.update(yet_more_training_data) |
cb6b945acf5a
Complete redesign of learner...
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
180
diff
changeset
|
95 |
cb6b945acf5a
Complete redesign of learner...
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
180
diff
changeset
|
96 and at any point one can use the model to perform some computation: |
cb6b945acf5a
Complete redesign of learner...
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
180
diff
changeset
|
97 |
cb6b945acf5a
Complete redesign of learner...
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
180
diff
changeset
|
98 output_dataset = model(input_dataset) |
cb6b945acf5a
Complete redesign of learner...
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
180
diff
changeset
|
99 |
262
14b9779622f9
Split LearningAlgorithm into OfflineLearningAlgorithm and OnlineLearningAlgorithm
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
211
diff
changeset
|
100 The model should be a LearnerModel subclass instance, and LearnerModel |
14b9779622f9
Split LearningAlgorithm into OfflineLearningAlgorithm and OnlineLearningAlgorithm
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
211
diff
changeset
|
101 is a subclass of LearnedModel. |
14b9779622f9
Split LearningAlgorithm into OfflineLearningAlgorithm and OnlineLearningAlgorithm
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
211
diff
changeset
|
102 |
1
2cd82666b9a7
Added statscollector and started writing dataset and learner.
bengioy@esprit.iro.umontreal.ca
parents:
0
diff
changeset
|
103 """ |
193
cb6b945acf5a
Complete redesign of learner...
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
180
diff
changeset
|
104 |
cb6b945acf5a
Complete redesign of learner...
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
180
diff
changeset
|
105 def __init__(self): pass |
cb6b945acf5a
Complete redesign of learner...
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
180
diff
changeset
|
106 |
cb6b945acf5a
Complete redesign of learner...
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
180
diff
changeset
|
107 def __call__(self, training_dataset=None): |
cb6b945acf5a
Complete redesign of learner...
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
180
diff
changeset
|
108 """ |
cb6b945acf5a
Complete redesign of learner...
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
180
diff
changeset
|
109 Return a LearnerModel, either fresh (if training_dataset is None) or fully trained (otherwise). |
cb6b945acf5a
Complete redesign of learner...
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
180
diff
changeset
|
110 """ |
cb6b945acf5a
Complete redesign of learner...
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
180
diff
changeset
|
111 raise AbstractFunction() |
1
2cd82666b9a7
Added statscollector and started writing dataset and learner.
bengioy@esprit.iro.umontreal.ca
parents:
0
diff
changeset
|
112 |
287
78cc8fe3bbe9
bugfix, bad object name
Frederic Bastien <bastienf@iro.umontreal.ca>
parents:
262
diff
changeset
|
113 class LearnerModel(TrainedModel): |
193
cb6b945acf5a
Complete redesign of learner...
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
180
diff
changeset
|
114 """ |
cb6b945acf5a
Complete redesign of learner...
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
180
diff
changeset
|
115 LearnerModel is a base class for models returned by instances of a LearningAlgorithm subclass. |
cb6b945acf5a
Complete redesign of learner...
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
180
diff
changeset
|
116 It is only given here to define the expected semantics. |
cb6b945acf5a
Complete redesign of learner...
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
180
diff
changeset
|
117 """ |
10
80bf5492e571
Rewrote learner.py according to the specs in the wiki for learners.
bengioy@esprit.iro.umontreal.ca
parents:
1
diff
changeset
|
118 def __init__(self): |
80bf5492e571
Rewrote learner.py according to the specs in the wiki for learners.
bengioy@esprit.iro.umontreal.ca
parents:
1
diff
changeset
|
119 pass |
80bf5492e571
Rewrote learner.py according to the specs in the wiki for learners.
bengioy@esprit.iro.umontreal.ca
parents:
1
diff
changeset
|
120 |
14 | 121 def update(self,training_set,train_stats_collector=None): |
10
80bf5492e571
Rewrote learner.py according to the specs in the wiki for learners.
bengioy@esprit.iro.umontreal.ca
parents:
1
diff
changeset
|
122 """ |
262
14b9779622f9
Split LearningAlgorithm into OfflineLearningAlgorithm and OnlineLearningAlgorithm
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
211
diff
changeset
|
123 Continue training a learner model, with the evidence provided by the given training set. |
193
cb6b945acf5a
Complete redesign of learner...
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
180
diff
changeset
|
124 Hence update can be called multiple times. This is the main method used for training in the |
10
80bf5492e571
Rewrote learner.py according to the specs in the wiki for learners.
bengioy@esprit.iro.umontreal.ca
parents:
1
diff
changeset
|
125 on-line setting or the sequential (Bayesian or not) settings. |
193
cb6b945acf5a
Complete redesign of learner...
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
180
diff
changeset
|
126 |
cb6b945acf5a
Complete redesign of learner...
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
180
diff
changeset
|
127 This function has as side effect that self(data) will behave differently, |
cb6b945acf5a
Complete redesign of learner...
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
180
diff
changeset
|
128 according to the adaptation achieved by update(). |
75
90e4c0784d6e
Added draft of LinearRegression learner
bengioy@bengiomac.local
parents:
20
diff
changeset
|
129 |
132
f6505ec32dc3
Updated documentation slightly
Joseph Turian <turian@gmail.com>
parents:
131
diff
changeset
|
130 The user may optionally provide a training L{StatsCollector} that is used to record |
75
90e4c0784d6e
Added draft of LinearRegression learner
bengioy@bengiomac.local
parents:
20
diff
changeset
|
131 some statistics of the outputs computed during training. It is update(d) during |
90e4c0784d6e
Added draft of LinearRegression learner
bengioy@bengiomac.local
parents:
20
diff
changeset
|
132 training. |
10
80bf5492e571
Rewrote learner.py according to the specs in the wiki for learners.
bengioy@esprit.iro.umontreal.ca
parents:
1
diff
changeset
|
133 """ |
193
cb6b945acf5a
Complete redesign of learner...
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents:
180
diff
changeset
|
134 raise AbstractFunction() |
10
80bf5492e571
Rewrote learner.py according to the specs in the wiki for learners.
bengioy@esprit.iro.umontreal.ca
parents:
1
diff
changeset
|
135 |