ReST Example (source)

features.rst

ReST Example
###############
:date: 2020-02-21 16:36:15
:publications_src: content/pages/zotero_single.bib
:toc_run: true
:status: hidden

Links
-----

`ReST documentation <https://docutils.sourceforge.io/rst.html#user-documentation>`__

Table (Playing with Kaggle; uses ReST includes)
-----------------------------------------------

--- snip ---

.. include:: ../includes/ffe/table.rst   

--- snap ---

(1) augmented: one additional variant per image rotated randomly in [-5,5] degree.
(2) bn: batch-norm 

Mathematics
-----------

*Inline Math:* :math:`f_{i}(x) = \int_{\tau(\pi)}^\infty e(x,y)dy`

*Display Math:*

.. math::

   \begin{bmatrix} 
   a_{11} & a_{12} & \dots \\
   \vdots & \ddots & \\
   a_{n1} &        & a_{nn} 
   \end{bmatrix}


*Inline Math:* :math:`(\Omega,\mathcal{F},P) \coloneqq  (\Omega^+\times\Omega^-,\mathcal{F^+}\otimes\mathcal{F^-},P^+\times P^-)`

*Display Math:*

The Wiener process in :math:`(\Omega,\mathcal{F},P)` is defined by

.. math::

   \omega(t) \coloneqq  
   \left\{
      \begin{array}{cc}
         (\omega^+(t),0) & t\geq 0 \\
         (0,\omega^-(t)) & t<0
      \end{array}
   \right.

More math ...

.. math::

   \tag{3.1a}
   \begin{aligned}
      dy_t &= \sum_{i=1}^n \frac{x_t^i}{\|x_t\|^2} \left( \sum_{j=1}^n
      u_{ij} x_t^i\,dt + \sum_{k=1}^m \sum_{j=1}^n v_{ij}^k
      x_t^j\circ dW_t^k\right) + \cdots\\
      \cdots &+ \frac{1}{2} \sum_{i,j}^n \left( \frac{\delta_{ij}}{\|x_t\|^2} -
      \frac{2x_t^i x_t^j}{\|x_t\|^4} \right)\; \sum_k^m \sum_{l,p}^n
      v_{il}^k v_{jp}^k\, x_t^l x_t^p\;dt
   \end{aligned}


With :math:`z_t \coloneqq \frac{x_t}{\|x_t\|}` we get the following differential equation on the unit sphere:   
   
.. math::

   \tag{3.1b}
   \begin{aligned}
      y_t &= y_0 + \int_0^t z_t^TUz_t- \|z_t\|^{-2}
      z_t^T\hat{V}\hat{V}^T z_t + \frac{1}{2}\text{ trace
      }(\hat{V}\hat{V}^T)\,dt +\cdots\\
      \cdots &+ \sum_{k=1}^m \int_0^t z_t^TV^kz_t\circ dW_t^k
   \end{aligned}

TeX file inclusion
^^^^^^^^^^^^^^^^^^

I was only able to include TeX as a ReST file containing the formulas as valid :code:`math` directive.

--- snip ---

.. include:: ../includes/ffe/formula_0.rst

--- snap ---

Single line:

--- snip ---

Single line (it seems, no real inlining is possible for ReST): start include -> 

.. include:: ../includes/ffe/formula_1.rst

<- stop include

--- snap ---


Footnotes
---------

Autonumbered footnotes are
possible, like using [#]_ and [#]_.

Citations
---------

- Cited text 1: [@@touchetteBasicIntroductionLarge2012]
- Cited text 2 [#]_ : [@dematteisRogueWavesLarge2018]


SVG Image
---------

The conversion of the following figure directive will use an <object> tag around the result. This might be blocked by noScript et al.

|

.. figure:: {static}/images/neuron.svg
   :align: center
   :width: 100%
   :figwidth: 50%
   :figclass: align-center

   Caption (Neuron image - 50%)


Code
----
Verbatim file inclusion 
^^^^^^^^^^^^^^^^^^^^^^^

.. include:: ../includes/ffe/features.py   
   :code:

Normal code block
^^^^^^^^^^^^^^^^^

.. code-block:: none

   from torch.utils.data import TensorDataset
   from torch import Tensor, LongTensor, FloatTensor


   def loadData(path) -> Tuple[np.ndarray, np.ndarray]:
      '''
      Load data from kaggle mnist set.

      path -- input csv

      Return scaled images [0,1] and labels (if available)
      as numpy arrays (dtype: float32, int64)
      '''
      # Read
      df = pd.read_csv(str(path))  # 40.000 entries
      # tdata = pd.read_csv(data_raw_dir + sep + 'train.csv') # 28.000 entries

      has_labels = True if 'label' in df.columns else False


Some :code:`inline code`.    


.. [#] First footnote  
.. [#] Second footnote  
.. [#] Interesting in terms of content, by the way

table.rst

================    ======   ==  ======  ======== ============== =============== ============
Model               Epochs   bs  lr      Momentum Result (local) Result (Kaggle) Remarks
================    ======   ==  ======  ======== ============== =============== ============
SimpleNet           50       20  0.007   0.9      ~97                  
ConvNet             50       25  0.008   0.9                     99.257
"                   50       17  0.008   0.9      99.1964                        augmented  
"                   50       17  0.008   0.9      99.3143        99.342          augmented bn
Binary Ensemble     25       17  0.007   0.9      >99                                       
"                   22       17  0.0085  0.9      99.23928       99.328          augmented  
"                   22       17  0.0085  0.9      99.34643       99.357          augmented bn
================    ======   ==  ======  ======== ============== =============== ============

formula_0.rst

.. math::
    \begin{aligned}
        z &= z(x, y)\\
        x &= x(s_1, s_2)\\
        y &= y(t_1, t_2)\\
        s_i &= s_i(w) \; \forall i \in \{1,2\} \\
        t_i &= t_i(w) \; \forall i \in \{1,2\} 
    \end{aligned}

formula_1.rst

:math:`{\partial z\over\partial w}={\partial z\over\partial x}\cdot\Bigg({\partial x\over\partial s_1}\cdot{\partial s_1\over\partial w}+{\partial x\over\partial s_2}\cdot{\partial s_2\over\partial w}\Bigg)+{\partial z\over\partial y}\cdot\Bigg({\partial y\over\partial t_1}\cdot{\partial t_1\over\partial w}+{\partial y\over\partial t_2}\cdot{\partial t_2\over\partial w}\Bigg)`