Mercurial > pylearn
comparison pylearn/sandbox/rbm/parameters.py @ 537:b054271b2504
new file structure layout, factories, etc.
author | James Bergstra <bergstrj@iro.umontreal.ca> |
---|---|
date | Wed, 12 Nov 2008 21:57:54 -0500 |
parents | sandbox/rbm/parameters.py@c2e6a8fcc35e |
children |
comparison
equal
deleted
inserted
replaced
518:4aa7f74ea93f | 537:b054271b2504 |
---|---|
1 """ | |
2 Parameters (weights) used by the L{Model}. | |
3 """ | |
4 | |
5 import numpy | |
6 | |
7 class Parameters: | |
8 """ | |
9 Parameters used by the L{Model}. | |
10 """ | |
11 def __init__(self, input_dimension, hidden_dimension, randomly_initialize, random_seed): | |
12 """ | |
13 Initialize L{Model} parameters. | |
14 @param randomly_initialize: If True, then randomly initialize | |
15 according to the given random_seed. If False, then just use zeroes. | |
16 """ | |
17 if randomly_initialize: | |
18 numpy.random.random_seed(random_seed) | |
19 self.w = (numpy.random.rand(input_dimension, hidden_dimension)-0.5)/input_dimension | |
20 self.b = numpy.zeros((1, hidden_dimension)) | |
21 self.c = numpy.zeros((1, input_dimension)) | |
22 else: | |
23 self.w = numpy.zeros((input_dimension, hidden_dimension)) | |
24 self.b = numpy.zeros((1, hidden_dimension)) | |
25 self.c = numpy.zeros((1, input_dimension)) | |
26 | |
27 def __str__(self): | |
28 s = "" | |
29 s += "w: %s\n" % self.w | |
30 s += "b: %s\n" % self.b | |
31 s += "c: %s\n" % self.c | |
32 return s |