diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pylearn/sandbox/rbm/parameters.py	Wed Nov 12 21:57:54 2008 -0500
@@ -0,0 +1,32 @@
+"""
+Parameters (weights) used by the L{Model}.
+"""
+
+import numpy
+
+class Parameters:
+    """
+    Parameters used by the L{Model}.
+    """
+    def __init__(self, input_dimension, hidden_dimension, randomly_initialize, random_seed):
+        """
+        Initialize L{Model} parameters.
+        @param randomly_initialize: If True, then randomly initialize
+        according to the given random_seed. If False, then just use zeroes.
+        """
+        if randomly_initialize:
+            numpy.random.random_seed(random_seed)
+            self.w = (numpy.random.rand(input_dimension, hidden_dimension)-0.5)/input_dimension
+            self.b = numpy.zeros((1, hidden_dimension))
+            self.c = numpy.zeros((1, input_dimension))
+        else:
+            self.w = numpy.zeros((input_dimension, hidden_dimension))
+            self.b = numpy.zeros((1, hidden_dimension))
+            self.c = numpy.zeros((1, input_dimension))
+
+    def __str__(self):
+        s = ""
+        s += "w: %s\n" % self.w
+        s += "b: %s\n" % self.b
+        s += "c: %s\n" % self.c
+        return s