Mercurial > pylearn
comparison sandbox/rbm/parameters.py @ 406:c2e6a8fcc35e
Globals are now parameters for the RBM model
author | Joseph Turian <turian@gmail.com> |
---|---|
date | Thu, 10 Jul 2008 02:10:23 -0400 |
parents | e0c9357456e0 |
children |
comparison
equal
deleted
inserted
replaced
405:be4209cd568f | 406:c2e6a8fcc35e |
---|---|
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 random_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.random_seed(random_seed) |
20 self.w = (numpy.random.rand(input_dimension, hidden_dimension)-0.5)/input_dimension | 19 self.w = (numpy.random.rand(input_dimension, hidden_dimension)-0.5)/input_dimension |
21 self.b = numpy.zeros((1, hidden_dimension)) | 20 self.b = numpy.zeros((1, hidden_dimension)) |
22 self.c = numpy.zeros((1, input_dimension)) | 21 self.c = numpy.zeros((1, input_dimension)) |
23 else: | 22 else: |
24 self.w = numpy.zeros((input_dimension, hidden_dimension)) | 23 self.w = numpy.zeros((input_dimension, hidden_dimension)) |