You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An Apply instance (`Apply API <http://lgcm.iro.umontreal.ca/epydoc/theano.gof.graph.Apply-class.html>`_)
12
-
represents the application of an :term:`Op` on input :term:`Results <Result>`, producing output :term:`Results <Result>`.
13
-
Users typically do not instantiate Apply directly, instead they should use an Op's ``make_node`` or ``__call__`` function.
14
-
15
-
Comparing with the Python language, an :term:`Apply` instance is theano's version of a function call (or expression instance) whereas :term:`Op` is theano's version of a function definition.
16
-
17
-
An Apply instance serves as a simple structure with three important fields:
18
-
``inputs``: a list of :term:`Result` instances that represent the arguments of the function.
19
-
``outputs``: a list of :term:`Result` instances that represent the return values of the function.
20
-
``op``: an Op instance that determines the function/transformation being applied here.
9
+
WRITEME
10
+
11
+
broadcasting
12
+
Broadcasting is a mechanism which allows tensors with
13
+
different numbers of dimensions to be added or multiplied
14
+
together by (virtually) replicating the smaller tensor along
15
+
the dimensions that it is lacking.
16
+
17
+
In a nutshell, broadcasting is the mechanism by which a scalar
18
+
may be added to a matrix, a vector to a matrix or a scalar to
19
+
a vector.
20
+
21
+
.. figure:: bcast.png
22
+
23
+
Broadcasting a row matrix. T and F respectively stand for
24
+
True and False and indicate along which dimensions we allow
25
+
broadcasting.
21
26
22
-
Theano.function uses the Apply instances' ``inputs`` field together with each :term:`Result`'s ``owner`` field to determine which inputs are necessary to compute the function's outputs.
23
-
Theano.function uses the Apply instances' ``op`` field to know how to compute the intermediate and final Results.
27
+
Unlike numpy which does broadcasting dynamically, Theano needs
28
+
to know, for any operation which supports broadcasting, which
29
+
dimensions will need to be broadcasted. When applicable, this
30
+
information is given in the :term:`Type` of a :term:`Result`.
24
31
25
-
See :ref:`intro_to_ops`.
32
+
For more information, see the article about broadcasting_.
26
33
27
-
Broadcasting
28
-
implicit tensor repmat
34
+
See also:
35
+
36
+
* `SciPy documentation about numpy's broadcasting <http://www.scipy.org/EricsBroadcastingDoc>`_
37
+
* `OnLamp article about numpy's broadcasting <http://www.onlamp.com/pub/a/python/2000/09/27/numerically.html>`_
38
+
39
+
constant
40
+
WRITEME
41
+
42
+
elementwise
43
+
An elementwise operation ``f`` on two matrices ``M`` and ``N``
44
+
is one such that:
29
45
46
+
``f(M, N)[i, j] = f(M[i, j], N[i, j])``
47
+
48
+
In other words, each element of an input matrix is combined
49
+
with the corresponding element of the other(s). There are no
50
+
dependencies between elements whose ``[i, j]`` coordinates do
51
+
not correspond, so an elementwise operation is like a scalar
52
+
operation generalized along several dimensions.
53
+
54
+
There exist unary, binary, ternary, etc. elementwise
55
+
operations and they can work on scalars, vectors, matrices,
56
+
etc. as long as all the inputs have the same dimensions or can
57
+
be :term:`broadcasted <broadcasting>` to the same dimensions.
58
+
59
+
Examples of elementwise operations in Theano: ``add, sub, mul,
60
+
div, neg, inv, log, exp, sin, cos, tan`` and many
61
+
others. These operations are all subclasses of :api:`Elemwise
62
+
<theano.tensor.elemwise.Elemwise>`.
63
+
64
+
graph
30
65
WRITEME
66
+
67
+
op
68
+
WRITEME
69
+
70
+
Result
71
+
A :ref:`result` is the main data structure you work with when
72
+
using Theano. The symbolic inputs that you operate on are
73
+
Results and what you get from applying various operations to
74
+
these inputs are also Results. For example, when I type
75
+
76
+
>>> x = theano.tensor.ivector()
77
+
>>> y = -x
78
+
79
+
``x`` and ``y`` are both Results, i.e. instances of the
80
+
:api:`Result <theano.gof.graph.Result>` class. The
81
+
:term:`Type` of both ``x`` and ``y`` is
82
+
``theano.tensor.ivector``.
83
+
84
+
For more information, see: :ref:`result`.
85
+
86
+
type
87
+
WRITEME
88
+
89
+
90
+
.. _broadcasting: concepts/broadcasting.html
91
+
92
+
93
+
94
+
95
+
96
+
97
+
98
+
99
+
100
+
101
+
102
+
103
+
104
+
105
+
106
+
107
+
108
+
109
+
110
+
111
+
112
+
113
+
114
+
115
+
116
+
117
+
118
+
119
+
120
+
121
+
122
+
123
+
124
+
125
+
126
+
127
+
128
+
129
+
..
130
+
Apply
131
+
TRANSFERRED
31
132
32
-
The following pages appear to describe broadcasting, but I haven't read over them:
0 commit comments