Commits

Olivier Grisel committed 91984b1

smaller default dimensions + added timing information

  • Participants
  • Parent commits 9b72a63
  • Branches sgd

Comments (0)

Files changed (2)

experiments/xp_movie_prediction.py

 import os
 import sys
+import time
 from cPickle import dump
 from cPickle import load
 from gumby.brain import Brain
 import logging
 logging.config.fileConfig("log.ini")
 
+log = logging.getLogger()
 
 CYCLES = 2
 
 
 if not os.path.exists(INPUTS_FILENAME) or not os.path.exists(OUTPUTS_FILENAME):
 
+    start = time.time()
     movies = [load_movie(os.path.join(MOVIES_DIRECTORY, fn))
               for fn in os.listdir(MOVIES_DIRECTORY) if fn.endswith(".pickle")]
+    # limit the size of the dataset
+    movies = movies[:10]
     BATCH_SIZE = sum(len(m) for m in movies)
 
     if not movies:
                "xp_movie2.py first" % MOVIES_DIRECTORY)
         sys.exit(1)
 
+    tn = 3
+    sn = (3, 3)
+    dimensions = (40, 30)
     b = Brain()
-    l0 = b.add_layer(dimensions=(40, 30), temporal_neighborhood=5,
-                     spatial_neighborhood=(5, 4), history_size=BATCH_SIZE + 5)
+    l0 = b.add_layer(dimensions=dimensions, temporal_neighborhood=tn,
+                     spatial_neighborhood=sn, history_size=BATCH_SIZE + tn)
 
-    ma = MovieAdapter(movies, brain=b, dimensions=(40, 30))
+    ma = MovieAdapter(movies, brain=b, dimensions=dimensions)
 
     # load the content of the movie data into a single layered brain so as to
     # use it's API to build training data suitable for evaluating algorithms
         #ma.plot_mse("raw_mse_last_100_detailed.png", only_last=100)
         #ma.plot_mse_gain_over_identity("gain_mse.png")
 
+    end_generation = time.time()
+    log.info("generated %d frames in %03fs", BATCH_SIZE, end_generation-start)
+
     # dump the data set on disk so as to be able to quickly reuse it later
     # without going through brain adapting again
     i, o = l0.build_training_set()
+
+    end_conversion = time.time()
+    log.info("converted %d frames to %d training points in %03fs",
+             BATCH_SIZE, len(i), end_conversion-end_generation)
+
     print "saving " + INPUTS_FILENAME
     dump(i, file(INPUTS_FILENAME, 'wb'))
 
     print "saving " + OUTPUTS_FILENAME
     dump(o, file(OUTPUTS_FILENAME, 'wb'))
 
+    log.info("saved %d training points in %0.3fs", len(i),
+             time.time() - end_conversion)
+
 else:
+    start = time.time()
     # reuse previously saved datasets
     print "loading " + INPUTS_FILENAME
     i = load(file(INPUTS_FILENAME))
     print "loading " + OUTPUTS_FILENAME
     o = load(file(OUTPUTS_FILENAME))
 
+    log.info("loaded %d frames in %0.3fs", len(i),
+             time.time() - start)
+
+
 [logger_root]
 level=INFO
 handlers=console
-# deactivate the default handler so that the test can set their own handler
-# handlers=console
 
 #
 # Handlers