comparison simple_autoassociator.py/parameters.py @ 386:a474341861fa

Added a simple AA
author Joseph Turian <turian@gmail.com>
date Tue, 08 Jul 2008 02:27:00 -0400
parents sparse_random_autoassociator/parameters.py@a1bbcde6b456
children dace8b9743af
comparison
equal deleted inserted replaced
385:db28ff3fb887 386:a474341861fa
1 """
2 Parameters (weights) used by the L{Model}.
3 """
4
5 import numpy
6 import globals
7
8 class Parameters:
9 """
10 Parameters used by the L{Model}.
11 """
12 def __init__(self, input_dimension=globals.INPUT_DIMENSION, hidden_dimension=globals.HIDDEN_DIMENSION, randomly_initialize=False, seed=globals.SEED):
13 """
14 Initialize L{Model} parameters.
15 @param randomly_initialize: If True, then randomly initialize
16 according to the given seed. If False, then just use zeroes.
17 """
18 if randomly_initialize:
19 numpy.random.seed(seed)
20 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
22 self.b1 = numpy.zeros(hidden_dimension)
23 self.b2 = numpy.zeros(input_dimension)
24 else:
25 self.w1 = numpy.zeros((input_dimension, hidden_dimension))
26 self.w2 = numpy.zeros((hidden_dimension, input_dimension))
27 self.b1 = numpy.zeros(hidden_dimension)
28 self.b2 = numpy.zeros(input_dimension)