提交 aba531c0 authored 作者: Frederic's avatar Frederic

Fix doc indentation. They are part of their section, not at the global scope.

上级 cb6e3a07
...@@ -77,30 +77,30 @@ ...@@ -77,30 +77,30 @@
Returns the softplus nonlinearity applied to x Returns the softplus nonlinearity applied to x
:Parameter: *x* - symbolic Tensor (or compatible) :Parameter: *x* - symbolic Tensor (or compatible)
:Return type: same as x :Return type: same as x
:Returns: elementwise softplus: :math:`softplus(x) = \log_e{\left(1 + \exp(x)\right)}`. :Returns: elementwise softplus: :math:`softplus(x) = \log_e{\left(1 + \exp(x)\right)}`.
.. note:: The underlying code will return an exact 0 if an element of x is too small. .. note:: The underlying code will return an exact 0 if an element of x is too small.
.. code-block:: python .. code-block:: python
x,y,b = T.dvectors('x','y','b') x,y,b = T.dvectors('x','y','b')
W = T.dmatrix('W') W = T.dmatrix('W')
y = T.nnet.softplus(T.dot(W,x) + b) y = T.nnet.softplus(T.dot(W,x) + b)
.. function:: softmax(x) .. function:: softmax(x)
Returns the softmax function of x: Returns the softmax function of x:
:Parameter: *x* symbolic **2D** Tensor (or compatible). :Parameter: *x* symbolic **2D** Tensor (or compatible).
:Return type: same as x :Return type: same as x
:Returns: a symbolic 2D tensor whose ijth element is :math:`softmax_{ij}(x) = \frac{\exp{x_{ij}}}{\sum_k\exp(x_{ik})}`. :Returns: a symbolic 2D tensor whose ijth element is :math:`softmax_{ij}(x) = \frac{\exp{x_{ij}}}{\sum_k\exp(x_{ik})}`.
The softmax function will, when applied to a matrix, compute the softmax values row-wise. The softmax function will, when applied to a matrix, compute the softmax values row-wise.
.. code-block:: python .. code-block:: python
x,y,b = T.dvectors('x','y','b') x,y,b = T.dvectors('x','y','b')
W = T.dmatrix('W') W = T.dmatrix('W')
y = T.nnet.softmax(T.dot(W,x) + b) y = T.nnet.softmax(T.dot(W,x) + b)
.. function:: binary_crossentropy(output,target) .. function:: binary_crossentropy(output,target)
...@@ -111,27 +111,27 @@ The softmax function will, when applied to a matrix, compute the softmax values ...@@ -111,27 +111,27 @@ The softmax function will, when applied to a matrix, compute the softmax values
* *output* - symbolic Tensor (or compatible) * *output* - symbolic Tensor (or compatible)
:Return type: same as target :Return type: same as target
:Returns: a symbolic tensor, where the following is applied elementwise :math:`crossentropy(t,o) = -(t\cdot log(o) + (1 - t) \cdot log(1 - o))`. :Returns: a symbolic tensor, where the following is applied elementwise :math:`crossentropy(t,o) = -(t\cdot log(o) + (1 - t) \cdot log(1 - o))`.
The following block implements a simple auto-associator with a sigmoid The following block implements a simple auto-associator with a
nonlinearity and a reconstruction error which corresponds to the binary sigmoid nonlinearity and a reconstruction error which corresponds
cross-entropy (note that this assumes that x will contain values between 0 and to the binary cross-entropy (note that this assumes that x will
1): contain values between 0 and 1):
.. code-block:: python .. code-block:: python
x, y, b = T.dvectors('x', 'y', 'b') x, y, b = T.dvectors('x', 'y', 'b')
W = T.dmatrix('W') W = T.dmatrix('W')
h = T.nnet.sigmoid(T.dot(W, x) + b) h = T.nnet.sigmoid(T.dot(W, x) + b)
x_recons = T.nnet.sigmoid(T.dot(V, h) + c) x_recons = T.nnet.sigmoid(T.dot(V, h) + c)
recon_cost = T.nnet.binary_crossentropy(x_recons, x).mean() recon_cost = T.nnet.binary_crossentropy(x_recons, x).mean()
.. function:: categorical_crossentropy(coding_dist,true_dist) .. function:: categorical_crossentropy(coding_dist,true_dist)
Return the cross-entropy between an approximating distribution and a true distribution. Return the cross-entropy between an approximating distribution and a true distribution.
The cross entropy between two probability distributions measures the average number of bits The cross entropy between two probability distributions measures the average number of bits
needed to identify an event from a set of possibilities, if a coding scheme is used based needed to identify an event from a set of possibilities, if a coding scheme is used based
on a given probability distribution q, rather than the "true" distribution p. Mathematically, this on a given probability distribution q, rather than the "true" distribution p. Mathematically, this
function computes :math:`H(p,q) = - \sum_x p(x) \log(q(x))`, where function computes :math:`H(p,q) = - \sum_x p(x) \log(q(x))`, where
p=true_dist and q=coding_dist. p=true_dist and q=coding_dist.
...@@ -145,15 +145,17 @@ cross-entropy (note that this assumes that x will contain values between 0 and ...@@ -145,15 +145,17 @@ cross-entropy (note that this assumes that x will contain values between 0 and
:Return type: tensor of rank one-less-than `coding_dist` :Return type: tensor of rank one-less-than `coding_dist`
.. note:: An application of the scenario where *true_dist* has a 1-of-N representation .. note:: An application of the scenario where *true_dist* has a
is in classification with softmax outputs. If `coding_dist` is the output of 1-of-N representation is in classification with softmax
the softmax and `true_dist` is a vector of correct labels, then the function outputs. If `coding_dist` is the output of the softmax and
will compute ``y_i = - \log(coding_dist[i, one_of_n[i]])``, which corresponds `true_dist` is a vector of correct labels, then the function
to computing the neg-log-probability of the correct class (which is typically will compute ``y_i = - \log(coding_dist[i, one_of_n[i]])``,
the training criterion in classification settings). which corresponds to computing the neg-log-probability of the
correct class (which is typically the training criterion in
classification settings).
.. code-block:: python .. code-block:: python
y = T.nnet.softmax(T.dot(W, x) + b) y = T.nnet.softmax(T.dot(W, x) + b)
cost = T.nnet.categorical_crossentropy(y, o) cost = T.nnet.categorical_crossentropy(y, o)
# o is either the above-mentioned 1-of-N vector or 2D tensor # o is either the above-mentioned 1-of-N vector or 2D tensor
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论