broadcast.rst 2.6 KB
Newer Older
1 2 3 4 5 6
.. broadcast.rst:

#########
Broadcast
#########

7 8 9 10 11
.. code-block:: cpp

   Broadcast  // Operation that produces a tensor based on arg's axes


12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
Description
===========

Operation whose ``output`` tensor ignores axes not in the ``arg``
tensor.

Inputs
------

+-----------------+-------------------------+--------------------------------+
| Name            | Element Type            | Shape                          |
+=================+=========================+================================+
| ``arg``         | Any                     | Any                            |
+-----------------+-------------------------+--------------------------------+

Attributes
----------

+---------------------+---------------+------------------------------------+
| Name                | Type          | Notes                              |
+=====================+===============+====================================+
| ``shape``           | ``Shape``     | The shape of the output.           |
+---------------------+---------------+------------------------------------+
| ``broadcast_axes``  | ``AxisSet``   | Axis positions in ``shape`` that   |
|                     |               | are broadcast.                     |
+---------------------+---------------+------------------------------------+


Outputs
-------

+-----------------+-------------------------+--------------------------------+
| Name            | Element Type            | Shape                          |
+=================+=========================+================================+
46
| ``output``      | Same as ``arg``         | Same as ``shape``              |
47 48 49 50 51 52 53 54 55
+-----------------+-------------------------+--------------------------------+

The shape of ``arg`` must match ``shape`` with elements in ``broadcast_axes`` removed.


For example, if ``arg`` is :math:`[a, b, c]` then

.. math::

56
   \mathtt{Broadcast(arg, Shape{2, 3}, AxisSet{0})} &=
57 58 59 60
   \begin{bmatrix}
   a & b & c\\
   a & b & c
   \end{bmatrix}\\
61
   \mathtt{Broadcast(arg, Shape{3, 2}, AxisSet{1})} &=
62 63 64 65 66 67 68 69 70 71 72 73
   \begin{bmatrix}
   a & a\\
   b & b\\
   c & c
   \end{bmatrix}


Mathematical Definition
=======================

For a coordinate :math:`C`, let :math:`p(C)` be a coordinate with the
axes in ``broadcast_axes`` removed.  For example, if
74
:math:`\mathtt{broadcast_axes}=\{1,3\}` then :math:`p([d_0, d_1,
75 76 77 78
d_2, d_3, d_4]) = [d_0, d_2, d_4]`.  Then

.. math::

79
   \mathtt{output}_C = \mathtt{arg}_{p(C)}.
80 81 82 83 84 85 86 87
   


Backprop
========

.. math::

88
   \overline{\mathtt{arg}} \leftarrow \mathtt{Sum}(\Delta, \mathtt{broadcast_axes}).
89 90 91 92 93 94
   

C++ Interface
=============

.. doxygenclass:: ngraph::op::Broadcast
95
   :project: ngraph
96
   :members: