softmax.rst 1.88 KB
Newer Older
adstraw's avatar
adstraw committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14
.. softmax.rst:

#######
Softmax
#######

.. code-block:: cpp

   Softmax  // Softmax operation


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

Scott Cyphers's avatar
Scott Cyphers committed
15
Produces a tensor of the same element type and shape as ``arg,``
adstraw's avatar
adstraw committed
16 17
where the value at each coordinate of ``output`` is the expine of the
value of the corresponding coordinate of ``arg`` divided by the sum
Scott Cyphers's avatar
Scott Cyphers committed
18
of the expine of all coordinates of ``arg`` in the specified ``axes.``
adstraw's avatar
adstraw committed
19 20 21 22 23 24 25 26 27 28

Inputs
------

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

29
Attributes
adstraw's avatar
adstraw committed
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
----------
+-----------------+----------------------------------------------------------------+
| Name            | Description                                                    |
+=================+================================================================+
| ``axes``        | The axis positions (0-based) on which to calculate the softmax |
+-----------------+----------------------------------------------------------------+

Outputs
-------

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


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

.. math::

Scott Cyphers's avatar
Scott Cyphers committed
52
   \mathtt{output}_{i} = \frac{\exp(\mathtt{arg}_{i})}{\sum_{j} \exp(\mathtt{arg}_{j})}
adstraw's avatar
adstraw committed
53 54 55 56 57 58 59


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

.. doxygenclass:: ngraph::op::Softmax
   :project: ngraph
60
   :members: m_axes