one_hot.rst 1.98 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
.. one_hot.rst:

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

.. code-block:: cpp

   OneHot  // One-hot expansion


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

Inputs
------

18 19 20 21 22
+-----------------+-------------------+---------------------------------------------------------+
| Name            | Element Type      | Shape                                                   |
+=================+===================+=========================================================+
| ``arg``         | Any integral type | :math:`d_1,\dots,d_{m-1},d_{m+1},\dots,d_n)~(n \geq 0)` |
+-----------------+-------------------+---------------------------------------------------------+
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

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
=============

60
.. doxygenclass:: ngraph::op::v0::OneHot
61 62
   :project: ngraph
   :members: