changeset 682:be6639fccecc

added option for custom path in tzanetakis
author James Bergstra <bergstrj@iro.umontreal.ca>
date Mon, 20 Apr 2009 16:52:55 -0400
parents 4497619e2955
children 0929be7f9e43
files pylearn/datasets/tzanetakis.py
diffstat 1 files changed, 9 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/pylearn/datasets/tzanetakis.py	Wed Apr 08 19:53:18 2009 -0400
+++ b/pylearn/datasets/tzanetakis.py	Mon Apr 20 16:52:55 2009 -0400
@@ -63,7 +63,7 @@
 class TzanetakisExample(theano.Op):
     """Return the i'th file, label pair from the Tzanetakis dataset."""
     @staticmethod
-    def read_tzanetakis_file():
+    def read_tracklist(alt_path_root=None):
         """Read the tzanetakis dataset file 
         :rtype: (list, list)
         :returns: paths, labels
@@ -74,7 +74,12 @@
         for line in tracklist:
             toks = line.split()
             try:
-                path.append(toks[0])
+                if alt_path_root is None:
+                    path.append(toks[0])
+                else:
+                    line_path = toks[0]
+                    file_name = line_path.split('/')[-1] 
+                    path.append(alt_path_root + '/' + file_name)
                 label.append(toks[1])
             except:
                 print 'BAD LINE IN TZANETAKIS TRACKLIST'
@@ -96,8 +101,8 @@
             reggae=8,
             rock=9)
             
-    def __init__(self):
-        self.path, self.label = self.read_tzanetakis_file()
+    def __init__(self, alt_path_root=None):
+        self.path, self.label = self.read_tracklist(alt_path_root)
         self.class_idx_dict = {}
         classes = ('blues classical country disco hiphop jazz metal pop reggae rock').split()
         for i, c in enumerate(classes):