Skip to content

Commit

Permalink
Merge pull request #3162 from niboshi/bp-fix-doctest-errors
Browse files Browse the repository at this point in the history
[Backport] Fix errors in docstrings
  • Loading branch information
mitmul committed Aug 16, 2017
2 parents feb3ad3 + f52aa66 commit cb7cc2b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
5 changes: 3 additions & 2 deletions chainer/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ def no_backprop_mode():
In this example, ``y`` is created in this context. So you cannot call
:func:`~chianer.Variable.backward`.
>>> x = chainer.Variable(numpy.array([1,], 'f'))
>>> x = chainer.Variable(np.array([1,], 'f'))
>>> with chainer.no_backprop_mode():
... y = x + 1
... y = x + 1
"""
return configuration.using_config('enable_backprop', False)
Expand All @@ -43,6 +43,7 @@ def force_backprop_mode():
In this example, ``y`` has a computational graph and ``y.backward``
computes gradients of variables in the graph.
>>> x = chainer.Variable(np.array([1,], 'f'))
>>> with chainer.no_backprop_mode():
... with chainer.force_backprop_mode():
... y = x + 1
Expand Down
6 changes: 4 additions & 2 deletions chainer/functions/activation/lstm.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,10 @@ def lstm(c_prev, x):
>>> y = chainer.Variable(np.zeros((1, n_units), 'f'))
>>> h = chainer.Variable(np.zeros((1, n_units), 'f'))
>>> c = chainer.Variable(np.zeros((1, n_units), 'f'))
>>> model = chainer.Chain(w=L.Linear(n_units, 4 * n_units),
... v=L.Linear(n_units, 4 * n_units),)
>>> model = chainer.Chain()
>>> with model.init_scope():
... model.w = L.Linear(n_units, 4 * n_units)
... model.v = L.Linear(n_units, 4 * n_units)
>>> x = model.w(y) + model.v(h)
>>> c, h = F.lstm(c, x)
Expand Down
12 changes: 8 additions & 4 deletions chainer/functions/activation/slstm.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,14 @@ def slstm(c_prev1, c_prev2, x1, x2):
>>> h2 = chainer.Variable(np.zeros((1, n_units), 'f'))
>>> c1 = chainer.Variable(np.zeros((1, n_units), 'f'))
>>> c2 = chainer.Variable(np.zeros((1, n_units), 'f'))
>>> model1 = chainer.Chain(w=L.Linear(n_units, 4 * n_units),
... v=L.Linear(n_units, 4 * n_units))
>>> model2 = chainer.Chain(w=L.Linear(n_units, 4 * n_units),
... v=L.Linear(n_units, 4 * n_units))
>>> model1 = chainer.Chain()
>>> with model1.init_scope():
... model1.w = L.Linear(n_units, 4 * n_units)
... model1.v = L.Linear(n_units, 4 * n_units)
>>> model2 = chainer.Chain()
>>> with model2.init_scope():
... model2.w = L.Linear(n_units, 4 * n_units)
... model2.v = L.Linear(n_units, 4 * n_units)
>>> x1 = model1.w(c1) + model1.v(h1)
>>> x2 = model2.w(c2) + model2.v(h2)
>>> c, h = F.slstm(c1, c2, x1, x2)
Expand Down

0 comments on commit cb7cc2b

Please sign in to comment.