comparison sandbox/simple_autoassociator/parameters.py @ 417:4f61201fa9a9

Parameters are no longer global
author Joseph Turian <turian@iro.umontreal.ca>
date Fri, 11 Jul 2008 17:19:37 -0400
parents faffaae0d2f9
children
comparison
equal deleted inserted replaced
416:8849eba55520 417:4f61201fa9a9
1 """ 1 """
2 Parameters (weights) used by the L{Model}. 2 Parameters (weights) used by the L{Model}.
3 """ 3 """
4 4
5 import numpy 5 import numpy
6 import globals
7 6
8 class Parameters: 7 class Parameters:
9 """ 8 """
10 Parameters used by the L{Model}. 9 Parameters used by the L{Model}.
11 """ 10 """
12 def __init__(self, input_dimension=globals.INPUT_DIMENSION, hidden_dimension=globals.HIDDEN_DIMENSION, randomly_initialize=False, seed=globals.SEED): 11 def __init__(self, input_dimension, hidden_dimension, randomly_initialize, random_seed):
13 """ 12 """
14 Initialize L{Model} parameters. 13 Initialize L{Model} parameters.
15 @param randomly_initialize: If True, then randomly initialize 14 @param randomly_initialize: If True, then randomly initialize
16 according to the given seed. If False, then just use zeroes. 15 according to the given seed. If False, then just use zeroes.
17 """ 16 """
18 if randomly_initialize: 17 if randomly_initialize:
19 numpy.random.seed(seed) 18 numpy.random.seed(random_seed)
20 self.w1 = (numpy.random.rand(input_dimension, hidden_dimension)-0.5)/input_dimension 19 self.w1 = (numpy.random.rand(input_dimension, hidden_dimension)-0.5)/input_dimension
21 self.w2 = (numpy.random.rand(hidden_dimension, input_dimension)-0.5)/hidden_dimension 20 self.w2 = (numpy.random.rand(hidden_dimension, input_dimension)-0.5)/hidden_dimension
22 self.b1 = numpy.zeros(hidden_dimension) 21 self.b1 = numpy.zeros(hidden_dimension)
23 self.b2 = numpy.zeros(input_dimension) 22 self.b2 = numpy.zeros(input_dimension)
24 #self.b2 = numpy.array([10, 0, 0, -10]) 23 #self.b2 = numpy.array([10, 0, 0, -10])