@@ -215,7 +215,7 @@ Optional methods or attributes
215
215
will use your Op and build the graphs that you want and call that
216
216
instead of the Op instance directly.
217
217
218
- .. function:: infer_shape(node, shapes)
218
+ .. function:: infer_shape(fgraph, node, shapes)
219
219
220
220
This function is needed for shape optimization. ``shapes`` is a
221
221
list with one tuple for each input of the Apply node (which corresponds
@@ -254,7 +254,7 @@ Optional methods or attributes
254
254
If you set `__props__`, this will be automatically generated.
255
255
You can still overide it for custom output.
256
256
257
- .. function:: do_constant_folding(node)
257
+ .. function:: do_constant_folding(fgraph, node)
258
258
259
259
*Default:* Return True
260
260
@@ -323,7 +323,7 @@ These are the function required to work with gradient.grad().
323
323
return the gradient of the Op's output. theano.tensor.grad computes
324
324
gradients; Op.grad is a helper function that computes terms that
325
325
appear in gradients.
326
-
326
+
327
327
If an Op has a single vector-valued output y and a single
328
328
vector-valued input x, then the grad method will be passed x and a
329
329
second vector z. Define J to be the Jacobian of y with respect to
@@ -393,7 +393,7 @@ These are the function required to work with gradient.grad().
393
393
:math:`[grad_{x_1}(C), grad_{x_2}(C), ..., grad_{x_m}(C)]`, where
394
394
:math:`(grad_{y}(Z))_i = \frac{\partial Z}{\partial y_i}` (and
395
395
:math:`i` can stand for multiple dimensions).
396
-
396
+
397
397
In other words, :func:`grad` does not return :math:`\frac{d f_i}{d
398
398
x_j}`, but instead the appropriate dot product specified by the
399
399
chain rule: :math:`\frac{d C}{d x_j} = \frac{d C}{d f_i} \cdot
@@ -402,7 +402,7 @@ These are the function required to work with gradient.grad().
402
402
403
403
Theano currently imposes the following constraints on the values
404
404
returned by the grad method:
405
-
405
+
406
406
1) They must be Variable instances.
407
407
2) When they are types that have dtypes, they must never have an integer dtype.
408
408
@@ -525,27 +525,27 @@ These are the function required to work with gradient.grad().
525
525
526
526
This function implements the application of the R-operator on the
527
527
function represented by your op. Let assume that function is :math:`f`,
528
- with input :math:`x`, applying the R-operator means computing the
529
- Jacobian of :math:`f` and right-multiplying it by :math:`v`, the evaluation
530
- point, namely: :math:`\frac{\partial f}{\partial x} v`.
528
+ with input :math:`x`, applying the R-operator means computing the
529
+ Jacobian of :math:`f` and right-multiplying it by :math:`v`, the evaluation
530
+ point, namely: :math:`\frac{\partial f}{\partial x} v`.
531
531
532
- ``inputs`` are the symbolic variables corresponding to the value of
532
+ ``inputs`` are the symbolic variables corresponding to the value of
533
533
the input where you want to evaluate the jacobian, and ``eval_points``
534
534
are the symbolic variables corresponding to the value you want to
535
- right multiply the jacobian with.
535
+ right multiply the jacobian with.
536
536
537
537
Same conventions as for the grad method hold. If your op is not
538
- differentiable, you can return None. Note that in contrast to
538
+ differentiable, you can return None. Note that in contrast to
539
539
the method :func:`grad`, for :func:`R_op` you need to return the
540
540
same number of outputs as there are ouputs of the op. You can think
541
541
of it in the following terms. You have all your inputs concatenated
542
- into a single vector :math:`x`. You do the same with the evaluation
542
+ into a single vector :math:`x`. You do the same with the evaluation
543
543
points (which are as many as inputs and of the shame shape) and obtain
544
- another vector :math:`v`. For each output, you reshape it into a vector,
545
- compute the jacobian of that vector with respect to :math:`x` and
544
+ another vector :math:`v`. For each output, you reshape it into a vector,
545
+ compute the jacobian of that vector with respect to :math:`x` and
546
546
multiply it by :math:`v`. As a last step you reshape each of these
547
- vectors you obtained for each outputs (that have the same shape as
548
- the outputs) back to their corresponding shapes and return them as the
547
+ vectors you obtained for each outputs (that have the same shape as
548
+ the outputs) back to their corresponding shapes and return them as the
549
549
output of the :func:`R_op` method.
550
550
551
551
:ref:`List of op with r op support <R_op_list>`.
@@ -777,4 +777,3 @@ your disposal to create these objects as efficiently as possible.
777
777
778
778
**Exercise**: Make a generic DoubleOp, where the number of
779
779
arguments can also be given as a parameter.
780
-
0 commit comments