one_hot.rst 2 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 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 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
.. one_hot.rst:

######
OneHot
######

.. code-block:: cpp

   OneHot  // One-hot expansion


Description
===========

Inputs
------

+-----------------+-------------------------+---------------------------------------------------------+
| Name            | Element Type            | Shape                                                   |
+=================+=========================+=========================================================+
| ``arg``         | Any                     | :math:`d_1,\dots,d_{m-1},d_{m+1},\dots,d_n)~(n \geq 0)` |
+-----------------+-------------------------+---------------------------------------------------------+

Attributes
----------

+------------------+----------------------------------------------------------------+
| Name             | Description                                                    |
+==================+================================================================+
| ``shape``        | The desired output shape, including the new one-hot axis.      |
+------------------+----------------------------------------------------------------+
| ``one_hot_axis`` | The index within the output shape of the new one-hot axis.     |
+------------------+----------------------------------------------------------------+


Outputs
-------

+-----------------+-------------------------+--------------------------------+
| Name            | Element Type            | Shape                          |
+=================+=========================+================================+
| ``output``      | Same as ``arg``         | ``shape``                      |
+-----------------+-------------------------+--------------------------------+


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

.. math::

   \mathtt{output}_{i_0, \ldots, i_{n-1}} =
   \begin{cases}
   1&\text{if }i_{\mathtt{one\_hot\_axis}} = \mathtt{arg}_{(i : i\ne \mathtt{one\_hot\_axis})}\\
   0&\text{otherwise}
   \end{cases}

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

.. doxygenclass:: ngraph::op::OneHot
   :project: ngraph
   :members: