comparison sandbox/rbm/parameters.py @ 395:70019965f888

Basic, broken RBM implementation
author Joseph Turian <turian@gmail.com>
date Tue, 08 Jul 2008 20:14:21 -0400
parents sandbox/simple_autoassociator/parameters.py@36baeb7125a4
children e0c9357456e0
comparison
equal deleted inserted replaced
394:f2d112dc53be 395:70019965f888
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.w = (numpy.random.rand(input_dimension, hidden_dimension)-0.5)/input_dimension
21 self.b = numpy.zeros(hidden_dimension)
22 self.c = numpy.zeros(input_dimension)
23 else:
24 self.w = numpy.zeros((input_dimension, hidden_dimension))
25 self.b = numpy.zeros(hidden_dimension)
26 self.c = numpy.zeros(input_dimension)
27
28 def __str__(self):
29 s = ""
30 s += "w: %s\n" % self.w
31 s += "b: %s\n" % self.b
32 s += "c: %s\n" % self.c
33 return s