提交 db0561fd authored 作者: Cesar Laurent's avatar Cesar Laurent

Added error message.

上级 63a6b7c3
...@@ -390,7 +390,7 @@ ensured by the user. Otherwise, it will result in an error. ...@@ -390,7 +390,7 @@ ensured by the user. Otherwise, it will result in an error.
Using the original Gibbs sampling example, with ``strict=True`` added to the Using the original Gibbs sampling example, with ``strict=True`` added to the
``scan()`` call: ``scan()`` call:
.. code-block:: python .. testcode:: scan1
# Same OneStep as in original example. # Same OneStep as in original example.
def OneStep(vsample) : def OneStep(vsample) :
...@@ -401,15 +401,39 @@ Using the original Gibbs sampling example, with ``strict=True`` added to the ...@@ -401,15 +401,39 @@ Using the original Gibbs sampling example, with ``strict=True`` added to the
dtype=theano.config.floatX) dtype=theano.config.floatX)
# The new scan, adding strict=True to the original call. # The new scan, adding strict=True to the original call.
# Produces an error, because W, bvis and bhid are used by OneStep, but not
# passed explicitly.
values, updates = theano.scan(OneStep, values, updates = theano.scan(OneStep,
outputs_info=sample, outputs_info=sample,
n_steps=10, n_steps=10,
strict=True) strict=True)
The above will result in an error, indicating that ``OneStep`` relies on .. testoutput:: scan1
variables that are not passed as its explicit arguments.
MissingInputError: An input of the graph, used to compute
InplaceDimShuffle{1,0}(<TensorType(float64, matrix)>), was not provided
and not given a value.Use the Theano flag exception_verbosity='high',for
more information on this error.
The error indicates that ``OneStep`` relies on variables that are not passed
as arguments explicitly. Here is the correct version, with the shared
variables passed explicitly to ``OneStep`` and to scan:
.. testcode:: scan1
# OneStep, with explicit use of the shared variables (W, bvis, bhid)
def OneStep(vsample, W, bvis, bhid) :
hmean = T.nnet.sigmoid(theano.dot(vsample, W) + bhid)
hsample = trng.binomial(size=hmean.shape, n=1, p=hmean)
vmean = T.nnet.sigmoid(theano.dot(hsample, W.T) + bvis)
return trng.binomial(size=vsample.shape, n=1, p=vmean,
dtype=theano.config.floatX)
# The new scan, adding strict=True to the original call, and passing
# expicitly W, bvis and bhid.
values, updates = theano.scan(OneStep,
outputs_info=sample,
non_sequences=[W, bvis, bhid],
n_steps=10,
strict=True)
Multiple outputs, several taps values - Recurrent Neural Network with Scan Multiple outputs, several taps values - Recurrent Neural Network with Scan
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论