changeset 918:bb8ef344d0a9

majorminer op - make it only work on one track at a time
author James Bergstra <bergstrj@iro.umontreal.ca>
date Fri, 19 Mar 2010 23:32:23 -0400
parents 09212b8a1edd
children 3901d06e2d96
files pylearn/dataset_ops/majorminer.py
diffstat 1 files changed, 7 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/pylearn/dataset_ops/majorminer.py	Fri Mar 19 23:31:38 2010 -0400
+++ b/pylearn/dataset_ops/majorminer.py	Fri Mar 19 23:32:23 2010 -0400
@@ -32,22 +32,20 @@
         return hash(type(self))
 
     def make_node(self, idx):
-        _idx = theano.tensor.as_tensor_variable(idx, ndim=1)
+        _idx = theano.tensor.as_tensor_variable(idx, ndim=0)
         return theano.Apply(self, 
                 [_idx], 
                 [theano.sparse.csr_matrix('MajorMiner.tag_counts'),
-                 theano.generic('MajorMiner.:track_path')])
+                 theano.generic('MajorMiner.track_path')])
     def perform(self, node, (idx,), out_storage):
         global _meta
-        lil = scipy.sparse.lil_matrix((len(idx), len(_meta.tags)), dtype='int8')
-        tracks = []
-        for j,i in enumerate(idx):
-            for tag_id, count in _meta.track_tags[i]:
-                lil[j,tag_id] = count
-            tracks.append(_meta.tracks[i])
+        lil = scipy.sparse.lil_matrix((1, len(_meta.tags)), dtype='int8')
+
+        for tag_id, count in _meta.track_tags[idx]:
+            lil[0,tag_id] = count
 
         out_storage[0][0] = lil.tocsr()
-        out_storage[1][0] = tracks
+        out_storage[1][0] = _meta.tracks[idx]
 
     def grad(self, inputs, output):
         return [None for i in inputs]