Skip to content

Commit

Permalink
Add binary mode in docstring.
Browse files Browse the repository at this point in the history
  • Loading branch information
Thrandis committed Feb 12, 2016
1 parent ced8b8b commit 34b73d5
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions blocks/serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@
>>> from blocks.serialization import dump, load
>>> import tarfile
>>> with open('main_loop.tar', 'w') as dst:
>>> with open('main_loop.tar', 'wb') as dst:
... dump(main_loop, dst)
>>> tarball = tarfile.open('main_loop.tar', 'r')
>>> tarball = tarfile.open('main_loop.tar', 'rb')
>>> tarball # doctest: +ELLIPSIS
<tarfile.TarFile object at ...>
>>> tarball.getnames()
Expand All @@ -63,10 +63,10 @@
Let's do something more interesting:
>>> with open('main_loop.tar', 'w') as dst:
>>> with open('main_loop.tar', 'wb') as dst:
... dump(main_loop, dst,
... parameters=main_loop.model.parameters)
>>> tarball = tarfile.open('main_loop.tar', 'r')
>>> tarball = tarfile.open('main_loop.tar', 'rb')
>>> tarball.getnames()
['_parameters', '_pkl']
Expand All @@ -85,15 +85,15 @@
The loading of the main loop as a whole still works:
>>> with open('main_loop.tar') as src:
>>> with open('main_loop.tar', 'rb') as src:
... main_loop_loaded = load(src)
>>> main_loop_loaded # doctest: +ELLIPSIS
<blocks.main_loop.MainLoop object at ...>
Additionally, this module provides convenience routine
:func:`load_parameters`:
>>> with open('main_loop.tar') as src:
>>> with open('main_loop.tar', 'rb') as src:
... parameters = load_parameters(src)
>>> sorted(parameters.keys()) # doctest: +ELLIPSIS
['/mlp/linear_0.W', '/mlp/linear_0.b', '/mlp/linear_1.W', '/mlp/line...]
Expand Down

0 comments on commit 34b73d5

Please sign in to comment.