changeset 1417:f49801e39fe3

TensorDataset - added single_shape and batch_size properties
author James Bergstra <bergstrj@iro.umontreal.ca>
date Fri, 04 Feb 2011 16:02:57 -0500
parents 28b2f17991aa
children 383d4c061546
files pylearn/dataset_ops/protocol.py
diffstat 1 files changed, 11 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/pylearn/dataset_ops/protocol.py	Fri Feb 04 16:01:45 2011 -0500
+++ b/pylearn/dataset_ops/protocol.py	Fri Feb 04 16:02:57 2011 -0500
@@ -48,15 +48,23 @@
     """
     def __init__(self, dtype, single_broadcastable, single_shape=None, batch_size=None):
         single_broadcastable = tuple(single_broadcastable)
+        self.single_shape = single_shape
+        self.batch_size = batch_size
         single_type = theano.tensor.Tensor(
-                broadcastable=single_broadcastable, 
+                broadcastable=single_broadcastable,
                 dtype=dtype)
-                #shape=single_shape)
         batch_type = theano.tensor.Tensor(
                 broadcastable=(False,)+single_type.broadcastable,
                 dtype=dtype)
-                #shape=(batch_size,)+single_type.shape)
         super(TensorDataset, self).__init__(single_type, batch_type)
+    def __eq__(self, other):
+        return (super(TensorDataset, self).__eq__(other)
+                and self.single_shape == other.single_shape
+                and self.batch_size == other.batch_size)
+    def __hash__(self):
+        return (super(TensorDataset, self).__hash__()
+                ^ hash(self.single_shape)
+                ^ hash(self.batch_size))
 
 class TensorFnDataset(TensorDataset):
     """A good base class for TensorDatasets that can be read from disk and cached in memory