comparison algorithms/logistic_regression.py @ 473:31acd42b2b0b

__instance_type__ -> InstanceType
author James Bergstra <bergstrj@iro.umontreal.ca>
date Thu, 23 Oct 2008 18:05:09 -0400
parents 69c800af1370
children 8fcd0f3d9a17
comparison
equal deleted inserted replaced
472:69c800af1370 473:31acd42b2b0b
7 7
8 import numpy as N 8 import numpy as N
9 9
10 10
11 class Module_Nclass(module.FancyModule): 11 class Module_Nclass(module.FancyModule):
12 class __instance_type__(module.FancyModuleInstance): 12 class InstanceType(module.FancyModuleInstance):
13 def initialize(self, n_in, n_out): 13 def initialize(self, n_in, n_out):
14 #self.component is the LogisticRegressionTemplate instance that built this guy. 14 #self.component is the LogisticRegressionTemplate instance that built this guy.
15 15
16 self.w = N.zeros((n_in, n_out)) 16 self.w = N.zeros((n_in, n_out))
17 self.b = N.zeros(n_out) 17 self.b = N.zeros(n_out)
46 46
47 self.update = module.Method([self.x, self.targ], sum_xent, 47 self.update = module.Method([self.x, self.targ], sum_xent,
48 updates = dict((p, p - self.lr * g) for p, g in zip(self.params, gparams))) 48 updates = dict((p, p - self.lr * g) for p, g in zip(self.params, gparams)))
49 49
50 class Module(module.FancyModule): 50 class Module(module.FancyModule):
51 class __instance_type__(module.FancyModuleInstance): 51 class InstanceType(module.FancyModuleInstance):
52 def initialize(self, n_in): 52 def initialize(self, n_in):
53 #self.component is the LogisticRegressionTemplate instance that built this guy. 53 #self.component is the LogisticRegressionTemplate instance that built this guy.
54 54
55 self.w = N.random.randn(n_in,1) 55 self.w = N.random.randn(n_in,1)
56 self.b = N.random.randn(1) 56 self.b = N.random.randn(1)