提交 01e67c7f authored 作者: Olivier Delalleau's avatar Olivier Delalleau

Fixed a number of typos in doc reported by eneftci

Also made sample code better PEP8-compliant, and fixed a minor typo in an error message. Fixes gh-1353
上级 50248b0f
...@@ -295,25 +295,26 @@ the following: ...@@ -295,25 +295,26 @@ the following:
.. code-block:: python .. code-block:: python
W = theano.shared ( W_values ) # we assume that ``W_values`` contains the W = theano.shared(W_values) # we assume that ``W_values`` contains the
# initial values of your weight matrix # initial values of your weight matrix
bvis = theano.shared( bvis_values) bvis = theano.shared(bvis_values)
bhid = theano.shared( bhid_values) bhid = theano.shared(bhid_values)
trng = T.shared_randomstreams.RandomStreams(1234) trng = T.shared_randomstreams.RandomStreams(1234)
def OneStep( vsample) : def OneStep(vsample) :
hmean = T.nnet.sigmoid( theano.dot( vsample, W) + bhid) hmean = T.nnet.sigmoid(theano.dot(vsample, W) + bhid)
hsample = trng.binomial( size = hmean.shape, n = 1, prob = hmean) hsample = trng.binomial(size=hmean.shape, n=1, p=hmean)
vmean = T.nnet.sigmoid( theano.dot( hsample. W.T) + bvis) vmean = T.nnet.sigmoid(theano.dot(hsample, W.T) + bvis)
return trng.binomial( size = vsample.shape, n = 1, prob = vsample) return trng.binomial(size=vsample.shape, n=1, p=vmean,
dtype=theano.config.floatX)
sample = theano.tensor.vector() sample = theano.tensor.vector()
values, updates = theano.scan( OneStep, outputs_info = sample, n_steps = 10 ) values, updates = theano.scan(OneStep, outputs_info=sample, n_steps=10)
gibbs10 = theano.function([sample], values[-1], updates = updates) gibbs10 = theano.function([sample], values[-1], updates=updates)
Note that if we use shared variables ( ``W``, ``bvis``, ``bhid``) but Note that if we use shared variables ( ``W``, ``bvis``, ``bhid``) but
...@@ -335,7 +336,7 @@ afterwards. Look at this example : ...@@ -335,7 +336,7 @@ afterwards. Look at this example :
.. code-block:: python .. code-block:: python
a = theano.shared(1) a = theano.shared(1)
values,updates = theano.scan( lambda : {a:a+1}, n_steps = 10 ) values, updates = theano.scan(lambda: {a: a+1}, n_steps=10)
In this case the lambda expression does not require any input parameters In this case the lambda expression does not require any input parameters
and returns an update dictionary which tells how ``a`` should be updated and returns an update dictionary which tells how ``a`` should be updated
...@@ -343,9 +344,9 @@ after each step of scan. If we write : ...@@ -343,9 +344,9 @@ after each step of scan. If we write :
.. code-block:: python .. code-block:: python
b = a+1 b = a + 1
c = updates[a] + 1 c = updates[a] + 1
f = theano.function([], [b,c], updates = updates) f = theano.function([], [b, c], updates=updates)
print b print b
print c print c
......
...@@ -228,7 +228,7 @@ class Scan(PureOp): ...@@ -228,7 +228,7 @@ class Scan(PureOp):
) )
err_msg2 = ('When compiling the inner function of scan the ' err_msg2 = ('When compiling the inner function of scan the '
'following error has been encountered: The ' 'following error has been encountered: The '
'initial state (outputs_info in scan nomenclature)' 'initial state (outputs_info in scan nomenclature) '
'of variable %s (argument number %d)' 'of variable %s (argument number %d)'
' has dtype %s and %d dimension(s), while the result ' ' has dtype %s and %d dimension(s), while the result '
'of the inner function for this output has dtype %s ' 'of the inner function for this output has dtype %s '
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论