diff algorithms/logistic_regression.py @ 519:b267a8000f92

Added theano.Member to Member variables which were passed in during initialization.
author Joseph Turian <turian@iro.umontreal.ca>
date Fri, 14 Nov 2008 02:07:20 -0500
parents c7ce66b4e8f4
children
line wrap: on
line diff
--- a/algorithms/logistic_regression.py	Mon Nov 03 00:10:18 2008 -0500
+++ b/algorithms/logistic_regression.py	Fri Nov 14 02:07:20 2008 -0500
@@ -8,7 +8,7 @@
 import numpy as N
 
 class LogRegInstanceType(module.FancyModuleInstance):
-    def initialize(self, n_in, n_out=1, rng=N.random, seed=None):
+    def initialize(self, n_in, n_out, lr, seed):
         #self.component is the LogisticRegressionTemplate instance that built this guy.
         """
         @todo: Remove seed. Used only to keep Stacker happy.
@@ -16,7 +16,7 @@
 
         self.w = N.zeros((n_in, n_out))
         self.b = N.zeros(n_out)
-        self.lr = 0.01
+        self.lr = lr
         self.__hide__ = ['params']
         self.input_dimension = n_in
         self.output_dimension = n_out
@@ -27,12 +27,12 @@
     def __init__(self, x=None, targ=None, w=None, b=None, lr=None, regularize=False):
         super(Module_Nclass, self).__init__() #boilerplate
 
-        self.x = x if x is not None else T.matrix('input')
-        self.targ = targ if targ is not None else T.lvector()
+        self.x = module.Member(x) if x is not None else T.matrix('input')
+        self.targ = module.Member(targ) if targ is not None else T.lvector()
 
-        self.w = w if w is not None else module.Member(T.dmatrix())
-        self.b = b if b is not None else module.Member(T.dvector())
-        self.lr = lr if lr is not None else module.Member(T.dscalar())
+        self.w = module.Member(w) if w is not None else module.Member(T.dmatrix())
+        self.b = module.Member(b) if b is not None else module.Member(T.dvector())
+        self.lr = module.Member(lr) if lr is not None else module.Member(T.dscalar())
 
         self.params = [p for p in [self.w, self.b] if p.owner is None]
 
@@ -77,12 +77,12 @@
     def __init__(self, input=None, targ=None, w=None, b=None, lr=None, regularize=False):
         super(Module, self).__init__() #boilerplate
 
-        self.input = input if input is not None else T.matrix('input')
-        self.targ = targ if targ is not None else T.lcol()
+        self.input = module.Member(input) if input is not None else T.matrix('input')
+        self.targ = module.Member(targ) if targ is not None else T.lcol()
 
-        self.w = w if w is not None else module.Member(T.dmatrix())
-        self.b = b if b is not None else module.Member(T.dvector())
-        self.lr = lr if lr is not None else module.Member(T.dscalar())
+        self.w = module.Member(w) if w is not None else module.Member(T.dmatrix())
+        self.b = module.Member(b) if b is not None else module.Member(T.dvector())
+        self.lr = module.Member(lr) if lr is not None else module.Member(T.dscalar())
 
         self.params = [p for p in [self.w, self.b] if p.owner is None]