Mercurial > pylearn
diff doc/seriestables.txt @ 929:34d1cd516f76
Added other targets (printing to stdout, notably) to seriestables, and corresponding doc
author | fsavard |
---|---|
date | Thu, 15 Apr 2010 09:11:14 -0400 |
parents | fdb63e4e042d |
children |
line wrap: on
line diff
--- a/doc/seriestables.txt Fri Apr 09 11:14:24 2010 -0400 +++ b/doc/seriestables.txt Thu Apr 15 09:11:14 2010 -0400 @@ -212,6 +212,74 @@ # where each element is a shared (as in theano.shared) array series['params'].append((epoch,), all_params) +Other targets for appending (e.g. printing to stdout) +----------------------------------------------------- + +SeriesTables was created with an HDF5 file in mind, but often, for debugging, +it's useful to be able to redirect the series elsewhere, notably the standard +output. A mechanism was added to do just that. + +What you do is you create a ``AppendTarget`` instance (or more than one) and +pass it as an argument to the Series constructor. For example, to print every +row appended to the standard output, you use StdoutAppendTarget. + +If you want to skip appending to the HDF5 file entirely, this is also +possible. You simply specify ``skip_hdf5_append=True`` in the constructor. You +still need to pass in a valid HDF5 file, though, even though nothing will be +written to it (for, err, legacy reasons). + +Here's an example: + +.. code-block:: python + + def create_series(num_hidden_layers): + + # Replace series we don't want to save with DummySeries, e.g. + # series['training_error'] = DummySeries() + + series = {} + + basedir = os.getcwd() + + h5f = tables.openFile(os.path.join(basedir, "series.h5"), "w") + + # Here we create the new target, with a message prepended + # before every row is printed to stdout + stdout_target = \ + StdoutAppendTarget( \ + prepend='\n-----------------\nValidation error', + indent_str='\t') + + # Notice here we won't even write to the HDF5 file + series['validation_error'] = \ + ErrorSeries(error_name="validation_error", + table_name="validation_error", + hdf5_file=h5f, + index_names=('epoch',), + other_targets=[stdout_target], + skip_hdf5_append=True) + + return series + + +Now calls to series['validation_error'].append() will print to stdout outputs +like:: + + ---------------- + Validation error + timestamp : 1271202144 + cpuclock : 0.12 + epoch : 1 + validation_error : 30.0 + + ---------------- + Validation error + timestamp : 1271202144 + cpuclock : 0.12 + epoch : 2 + validation_error : 26.0 + + Visualizing in vitables ----------------------- @@ -220,3 +288,4 @@ .. _vitables: http://vitables.berlios.de/ .. image:: images/vitables_example_series.png +