Mercurial > pylearn
comparison sandbox/simple_autoassociator/parameters.py @ 393:36baeb7125a4
Made sandbox directory
author | Joseph Turian <turian@gmail.com> |
---|---|
date | Tue, 08 Jul 2008 18:46:26 -0400 |
parents | simple_autoassociator/parameters.py@ec8aadb6694d |
children | 8cc11ac97087 |
comparison
equal
deleted
inserted
replaced
392:e2cb8d489908 | 393:36baeb7125a4 |
---|---|
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) | |
29 | |
30 def __str__(self): | |
31 s = "" | |
32 s += "w1: %s\n" % self.w1 | |
33 s += "b1: %s\n" % self.b1 | |
34 s += "w2: %s\n" % self.w2 | |
35 s += "b2: %s\n" % self.b2 | |
36 return s |