diff learner.py @ 78:3499918faa9d

In the middle of designing TLearner
author bengioy@bengiomac.local
date Mon, 05 May 2008 09:35:30 -0400
parents 1e2bb5bad636
children c4726e19b8ec
line wrap: on
line diff
--- a/learner.py	Sun May 04 15:09:22 2008 -0400
+++ b/learner.py	Mon May 05 09:35:30 2008 -0400
@@ -57,4 +57,35 @@
         """
         raise NotImplementedError
 
+    def attribute_names(self):
+        """
+        A Learner may have attributes that it wishes to export to other objects. To automate
+        such export, sub-classes should define here the names (list of strings) of these attributes.
+        """
+        return []
 
+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.
+
+    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
+                          None are provided by the caller of use.
+      - 
+      
+    """
+