Mercurial > pylearn
comparison 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 |
comparison
equal
deleted
inserted
replaced
928:87d416e1f4fd | 929:34d1cd516f76 |
---|---|
210 | 210 |
211 # suppose all_params is a list [layer1_W, layer1_b, ...] | 211 # suppose all_params is a list [layer1_W, layer1_b, ...] |
212 # where each element is a shared (as in theano.shared) array | 212 # where each element is a shared (as in theano.shared) array |
213 series['params'].append((epoch,), all_params) | 213 series['params'].append((epoch,), all_params) |
214 | 214 |
215 Other targets for appending (e.g. printing to stdout) | |
216 ----------------------------------------------------- | |
217 | |
218 SeriesTables was created with an HDF5 file in mind, but often, for debugging, | |
219 it's useful to be able to redirect the series elsewhere, notably the standard | |
220 output. A mechanism was added to do just that. | |
221 | |
222 What you do is you create a ``AppendTarget`` instance (or more than one) and | |
223 pass it as an argument to the Series constructor. For example, to print every | |
224 row appended to the standard output, you use StdoutAppendTarget. | |
225 | |
226 If you want to skip appending to the HDF5 file entirely, this is also | |
227 possible. You simply specify ``skip_hdf5_append=True`` in the constructor. You | |
228 still need to pass in a valid HDF5 file, though, even though nothing will be | |
229 written to it (for, err, legacy reasons). | |
230 | |
231 Here's an example: | |
232 | |
233 .. code-block:: python | |
234 | |
235 def create_series(num_hidden_layers): | |
236 | |
237 # Replace series we don't want to save with DummySeries, e.g. | |
238 # series['training_error'] = DummySeries() | |
239 | |
240 series = {} | |
241 | |
242 basedir = os.getcwd() | |
243 | |
244 h5f = tables.openFile(os.path.join(basedir, "series.h5"), "w") | |
245 | |
246 # Here we create the new target, with a message prepended | |
247 # before every row is printed to stdout | |
248 stdout_target = \ | |
249 StdoutAppendTarget( \ | |
250 prepend='\n-----------------\nValidation error', | |
251 indent_str='\t') | |
252 | |
253 # Notice here we won't even write to the HDF5 file | |
254 series['validation_error'] = \ | |
255 ErrorSeries(error_name="validation_error", | |
256 table_name="validation_error", | |
257 hdf5_file=h5f, | |
258 index_names=('epoch',), | |
259 other_targets=[stdout_target], | |
260 skip_hdf5_append=True) | |
261 | |
262 return series | |
263 | |
264 | |
265 Now calls to series['validation_error'].append() will print to stdout outputs | |
266 like:: | |
267 | |
268 ---------------- | |
269 Validation error | |
270 timestamp : 1271202144 | |
271 cpuclock : 0.12 | |
272 epoch : 1 | |
273 validation_error : 30.0 | |
274 | |
275 ---------------- | |
276 Validation error | |
277 timestamp : 1271202144 | |
278 cpuclock : 0.12 | |
279 epoch : 2 | |
280 validation_error : 26.0 | |
281 | |
282 | |
215 Visualizing in vitables | 283 Visualizing in vitables |
216 ----------------------- | 284 ----------------------- |
217 | 285 |
218 vitables_ is a program with which you can easily explore an HDF5 ``.h5`` file. Here's a screenshot in which I visualize series produced for the preceding example: | 286 vitables_ is a program with which you can easily explore an HDF5 ``.h5`` file. Here's a screenshot in which I visualize series produced for the preceding example: |
219 | 287 |
220 .. _vitables: http://vitables.berlios.de/ | 288 .. _vitables: http://vitables.berlios.de/ |
221 | 289 |
222 .. image:: images/vitables_example_series.png | 290 .. image:: images/vitables_example_series.png |
291 |