diff learner.py @ 167:4803cb76e26b

Updated documentation
author Joseph Turian <turian@gmail.com>
date Mon, 12 May 2008 18:51:42 -0400
parents ceae4de18981
children fb4837eed1a6
line wrap: on
line diff
--- a/learner.py	Mon May 12 18:40:17 2008 -0400
+++ b/learner.py	Mon May 12 18:51:42 2008 -0400
@@ -13,7 +13,6 @@
     A L{Learner} can be seen as a learning algorithm, a function that when
     applied to training data returns a learned function (which is an object that
     can be applied to other data and return some output data).
-    
     """
     
     def __init__(self):
@@ -169,34 +168,42 @@
     
 class TLearner(Learner):
     """
-    TLearner is a virtual class of Learners that attempts to factor out of the definition
-    of a learner the steps that are common to many implementations of learning algorithms,
-    so as to leave only 'the equations' to define in particular sub-classes, using Theano.
+    TLearner is a virtual class of L{Learner}s that attempts to factor
+    out of the definition of a learner the steps that are common to
+    many implementations of learning algorithms, so as to leave only
+    'the equations' to define in particular sub-classes, using Theano.
 
-    In the default implementations of use and update, it is assumed that the 'use' and 'update' methods
-    visit examples in the input dataset sequentially. In the 'use' method only one pass through the dataset is done,
-    whereas the sub-learner may wish to iterate over the examples multiple times. Subclasses where this
-    basic model is not appropriate can simply redefine update or use.
-    
+    In the default implementations of use and update, it is assumed
+    that the 'use' and 'update' methods visit examples in the input
+    dataset sequentially. In the 'use' method only one pass through the
+    dataset is done, whereas the sub-learner may wish to iterate over
+    the examples multiple times. Subclasses where this basic model is
+    not appropriate can simply redefine update or use.
+
     Sub-classes must provide the following functions and functionalities:
-      - attributeNames(): defines all the names of attributes which can be used as fields or
-                          attributes in input/output datasets or in stats collectors.
-                          All these attributes are expected to be theano.Result objects
-                          (with a .data property and recognized by theano.Function for compilation).
-                          The sub-class constructor defines the relations between
-                          the Theano variables that may be used by 'use' and 'update'
-                          or by a stats collector.
-      - defaultOutputFields(input_fields): return a list of default dataset output fields when
+      - attributeNames(): defines all the names of attributes which can
+      be used as fields or
+                          attributes in input/output datasets or in
+                          stats collectors.  All these attributes
+                          are expected to be theano.Result objects
+                          (with a .data property and recognized by
+                          theano.Function for compilation).  The sub-class
+                          constructor defines the relations between the
+                          Theano variables that may be used by 'use'
+                          and 'update' or by a stats collector.
+      - defaultOutputFields(input_fields): return a list of default
+      dataset output fields when
                           None are provided by the caller of use.
-    The following naming convention is assumed and important.
-    Attributes whose names are listed in attributeNames() can be of any type,
-    but those that can be referenced as input/output dataset fields or as
-    output attributes in 'use' or as input attributes in the stats collector
-    should be associated with a Theano Result variable. If the exported attribute
-    name is <name>, the corresponding Result name (an internal attribute of
-    the TLearner, created in the sub-class constructor) should be _<name>.
-    Typically <name> will be numpy ndarray and _<name> will be the corresponding
-    Theano Tensor (for symbolic manipulation).
+    The following naming convention is assumed and important.  Attributes
+    whose names are listed in attributeNames() can be of any type,
+    but those that can be referenced as input/output dataset fields or
+    as output attributes in 'use' or as input attributes in the stats
+    collector should be associated with a Theano Result variable. If the
+    exported attribute name is <name>, the corresponding Result name
+    (an internal attribute of the TLearner, created in the sub-class
+    constructor) should be _<name>.  Typically <name> will be numpy
+    ndarray and _<name> will be the corresponding Theano Tensor (for
+    symbolic manipulation).
 
     @todo pousser dans Learner toute la poutine qui peut l'etre sans etre
     dependant de Theano
@@ -252,19 +259,20 @@
 
 class MinibatchUpdatesTLearner(TLearner):
     """
-    This adds to L{TLearner} a 
+    This adds the following functions to a L{TLearner}:
       - updateStart(), updateEnd(), updateMinibatch(minibatch), isLastEpoch():
-                          functions executed at the beginning, the end, in the middle
-                          (for each minibatch) of the update method, and at the end
-                          of each epoch. This model only
-                          works for 'online' or one-shot learning that requires
-                          going only once through the training data. For more complicated
-                          models, more specialized subclasses of TLearner should be used
-                          or a learning-algorithm specific update method should be defined.
+      functions executed at the beginning, the end, in the middle (for
+      each minibatch) of the update method, and at the end of each
+      epoch. This model only works for 'online' or one-shot learning
+      that requires going only once through the training data. For more
+      complicated models, more specialized subclasses of TLearner should
+      be used or a learning-algorithm specific update method should
+      be defined.
 
-      - a 'parameters' attribute which is a list of parameters (whose names are
-      specified by the user's subclass with the parameterAttributes() method)
-      
+      - a 'parameters' attribute which is a list of parameters
+      (whose names are specified by the user's subclass with the
+      parameterAttributes() method)
+
     """
 
     def __init__(self):