texlive[73627] Master: mp-neuralnetwork (27jan25)
commits+karl at tug.org
commits+karl at tug.org
Tue Jan 28 22:09:25 CET 2025
Revision: 73627
https://tug.org/svn/texlive?view=revision&revision=73627
Author: karl
Date: 2025-01-28 22:09:25 +0100 (Tue, 28 Jan 2025)
Log Message:
-----------
mp-neuralnetwork (27jan25)
Modified Paths:
--------------
trunk/Master/tlpkg/bin/tlpkg-ctan-check
trunk/Master/tlpkg/libexec/ctan2tds
trunk/Master/tlpkg/tlpsrc/collection-metapost.tlpsrc
Added Paths:
-----------
trunk/Master/texmf-dist/doc/metapost/mp-neuralnetwork/
trunk/Master/texmf-dist/doc/metapost/mp-neuralnetwork/LICENSE
trunk/Master/texmf-dist/doc/metapost/mp-neuralnetwork/README.md
trunk/Master/texmf-dist/doc/metapost/mp-neuralnetwork/ctan.bib
trunk/Master/texmf-dist/doc/metapost/mp-neuralnetwork/fond.pdf
trunk/Master/texmf-dist/doc/metapost/mp-neuralnetwork/mp-neuralnetwork-doc-en.pdf
trunk/Master/texmf-dist/doc/metapost/mp-neuralnetwork/mp-neuralnetwork-doc-en.tex
trunk/Master/texmf-dist/doc/metapost/mp-neuralnetwork/mp-neuralnetwork-preamble.tex
trunk/Master/texmf-dist/metapost/mp-neuralnetwork/
trunk/Master/texmf-dist/metapost/mp-neuralnetwork/mp-neuralnetwork-metaobj-patch.mp
trunk/Master/texmf-dist/metapost/mp-neuralnetwork/mp-neuralnetwork.mp
trunk/Master/tlpkg/tlpsrc/mp-neuralnetwork.tlpsrc
Added: trunk/Master/texmf-dist/doc/metapost/mp-neuralnetwork/LICENSE
===================================================================
--- trunk/Master/texmf-dist/doc/metapost/mp-neuralnetwork/LICENSE (rev 0)
+++ trunk/Master/texmf-dist/doc/metapost/mp-neuralnetwork/LICENSE 2025-01-28 21:09:25 UTC (rev 73627)
@@ -0,0 +1,11 @@
+
+This work may be distributed and/or modified under the
+conditions of the LaTeX Project Public License, either version 1.3c
+of this license or (at your option) any later version.
+The latest version of this license is in
+ http://www.latex-project.org/lppl.txt
+and version 1.3c or later is part of all distributions of LaTeX
+version 2005/12/01 or later.
+
+This work has the LPPL maintenance status “maintained”.
+
Added: trunk/Master/texmf-dist/doc/metapost/mp-neuralnetwork/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/metapost/mp-neuralnetwork/README.md (rev 0)
+++ trunk/Master/texmf-dist/doc/metapost/mp-neuralnetwork/README.md 2025-01-28 21:09:25 UTC (rev 73627)
@@ -0,0 +1,16 @@
+# Neural Network with MetaPost
+
+This METAPOST package allows to draw artificial neural networks. It is
+based on the METAOBJ package which provides many tools to draw and
+arrange nodes.
+
+This package is in beta version—do not hesitate to report bugs, as well as
+requests for improvement.
+
+## Contact
+
+Maxime Chupin, `notezik(at)gmail.com`
+
+## Licenses
+
+This projet is under LATEX Project Public License 1.3c.
\ No newline at end of file
Property changes on: trunk/Master/texmf-dist/doc/metapost/mp-neuralnetwork/README.md
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/doc/metapost/mp-neuralnetwork/ctan.bib
===================================================================
--- trunk/Master/texmf-dist/doc/metapost/mp-neuralnetwork/ctan.bib (rev 0)
+++ trunk/Master/texmf-dist/doc/metapost/mp-neuralnetwork/ctan.bib 2025-01-28 21:09:25 UTC (rev 73627)
@@ -0,0 +1,56 @@
+
+ at manual{ctan-metapost,
+ title = {The \texttt{metapost} package},
+ subtitle = {A development of Metafont for creating graphics},
+ author = {{The MetaPost Team} and John Hobby},
+ date = {2021-08-26},
+ license = {lgpl},
+ url = {https://ctan.org/pkg/metapost},
+ annotation = {MetaPost uses a language based on that of
+ to produce precise
+ technical illustrations. Its output is scalable PostScript or
+ SVG, rather than the bitmaps Metafont creates.},
+}
+
+
+ at manual{ctan-metaobj,
+ title = {The \texttt{metaobj} package},
+ subtitle = {MetaPost package providing high-level objects},
+ author = {Denis B. Roegel},
+ date = {2016-06-24},
+ version = {0.93},
+ license = {lppl},
+ mirror = {https://mirror.ctan.org/graphics/metapost/contrib/macros/metaobj},
+ url = {https://ctan.org/pkg/metaobj},
+}
+
+
+ at manual{ctan-latexmp,
+ title = {The \texttt{latexMP} package},
+ subtitle = {Interface for \LaTeX{}-based typesetting in MetaPost},
+ author = {Jens-Uwe Morawski},
+ date = {2020-06-21},
+ version = {1.2.1},
+ license = {pd},
+ mirror = {https://mirror.ctan.org/graphics/metapost/contrib/macros/latexmp},
+ url = {https://ctan.org/pkg/latexmp},
+ annotation = {The MetaPost package latexMP implements a user-friendly
+ interface to access \LaTeX{}-based typesetting capabilities in
+ MetaPost. The text to be typeset is given as string. This
+ allows even dynamic text elements, for example counters, to be
+ used in labels. Compared to other implementations it is much
+ more flexible, since it can be used as direct replacement for
+ , and much faster, compared for example to the
+ solution provided by .},
+}
+
+ at manual{ctan-metapost-colorbrewer,
+ title = {The \texttt{metapost-colorbrewer} package},
+ subtitle = {An implementation of the colorbrewer2.org colours for MetaPost},
+ author = {Toby Thurston},
+ date = {2018-09-25},
+ version = {},
+ license = {gpl3+},
+ mirror = {https://mirror.ctan.org/graphics/metapost/contrib/macros/metapost-colorbrewer},
+ url = {https://ctan.org/pkg/metapost-colorbrewer},
+}
\ No newline at end of file
Property changes on: trunk/Master/texmf-dist/doc/metapost/mp-neuralnetwork/ctan.bib
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/doc/metapost/mp-neuralnetwork/fond.pdf
===================================================================
(Binary files differ)
Index: trunk/Master/texmf-dist/doc/metapost/mp-neuralnetwork/fond.pdf
===================================================================
--- trunk/Master/texmf-dist/doc/metapost/mp-neuralnetwork/fond.pdf 2025-01-28 21:08:01 UTC (rev 73626)
+++ trunk/Master/texmf-dist/doc/metapost/mp-neuralnetwork/fond.pdf 2025-01-28 21:09:25 UTC (rev 73627)
Property changes on: trunk/Master/texmf-dist/doc/metapost/mp-neuralnetwork/fond.pdf
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/pdf
\ No newline at end of property
Added: trunk/Master/texmf-dist/doc/metapost/mp-neuralnetwork/mp-neuralnetwork-doc-en.pdf
===================================================================
(Binary files differ)
Index: trunk/Master/texmf-dist/doc/metapost/mp-neuralnetwork/mp-neuralnetwork-doc-en.pdf
===================================================================
--- trunk/Master/texmf-dist/doc/metapost/mp-neuralnetwork/mp-neuralnetwork-doc-en.pdf 2025-01-28 21:08:01 UTC (rev 73626)
+++ trunk/Master/texmf-dist/doc/metapost/mp-neuralnetwork/mp-neuralnetwork-doc-en.pdf 2025-01-28 21:09:25 UTC (rev 73627)
Property changes on: trunk/Master/texmf-dist/doc/metapost/mp-neuralnetwork/mp-neuralnetwork-doc-en.pdf
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/pdf
\ No newline at end of property
Added: trunk/Master/texmf-dist/doc/metapost/mp-neuralnetwork/mp-neuralnetwork-doc-en.tex
===================================================================
--- trunk/Master/texmf-dist/doc/metapost/mp-neuralnetwork/mp-neuralnetwork-doc-en.tex (rev 0)
+++ trunk/Master/texmf-dist/doc/metapost/mp-neuralnetwork/mp-neuralnetwork-doc-en.tex 2025-01-28 21:09:25 UTC (rev 73627)
@@ -0,0 +1,520 @@
+
+% LTeX: language=en
+
+% huffman : draw binary huffman trees with MetaPost/MetaObj
+%
+% Originally written by Maxime Chupin <notezik at gmail.com>,
+% 2023.
+%
+% Distributed under the terms of the GNU free documentation licence:
+% http://www.gnu.org/licenses/fdl.html
+% without any invariant section or cover text.
+
+\documentclass[english]{ltxdoc}
+
+\input{mp-neuralnetwork-preamble.tex}
+
+\usepackage[english]{babel}
+
+\makeindex[title=Command Index, columns=2]
+
+
+
+%\lstset{moredelim=*[s][\color{red}\rmfamily\itshape]{<}{>}}
+%\lstset{moredelim=*[s][\color{blue}\rmfamily\itshape]{<<}{>>}}
+
+\begin{document}
+
+\title{{\mpneural} : drawing artificial neural networks with \MP and \MO/}
+\author{Maxime Chupin, \url{notezik at gmail.com}}
+\date{\today}
+
+%% === Page de garde ===================================================
+\thispagestyle{empty}
+\begin{tikzpicture}[remember picture, overlay]
+ \node[below right, shift={(-4pt,4pt)}] at (current page.north west) {%
+ \includegraphics{fond.pdf}%
+ };
+\end{tikzpicture}%
+
+\noindent
+{\Huge \mpneural}\par\bigskip
+\noindent
+{\Large drawing artificial neural networks \\[0.2cm]with \hologo{METAPOST} and \MO/}\\[1cm]
+\parbox{0.6\textwidth}{
+ \begin{mplibcode}[mpneural]
+ input mp-neuralnetwork;
+
+
+beginfig(1);
+framed_output(false);
+framed_input(false);
+drawANN("x","n","a","p","b","q","y","m") "circmargin(3pt)";
+endfig;
+ \end{mplibcode}
+}\hfill
+\parbox{0.5\textwidth}{\Large\raggedleft
+ \textbf{Contributor}\\
+ Maxime \textsc{Chupin}\\
+ \url{notezik at gmail.com}
+}
+\vfill
+\begin{center}
+ Version 0.1, 2025, January, 27th \\
+ \url{https://gitlab.gutenberg-asso.fr/mchupin/mp-neuralnetwork}
+\end{center}
+%% == Page de garde ====================================================
+\newpage
+
+%\maketitle
+
+\begin{abstract}
+ This \hologo{METAPOST} package allows to draw artificial neural networks.
+ It is based on the \MO/ package which
+ provides many tools to draw and arrange nodes.
+\end{abstract}
+
+
+\begin{center}
+ \url{https://gitlab.gutenberg-asso.fr/mchupin/mp-neuralnetwork}
+\end{center}
+
+\tableofcontents
+
+
+
+\bigskip
+
+\begin{tcolorbox}[ arc=0pt,outer arc=0pt,
+ colback=darkred!3,
+ colframe=darkred,
+ breakable,
+ boxsep=0pt,left=5pt,right=5pt,top=5pt,bottom=5pt, bottomtitle =
+ 3pt, toptitle=3pt,
+ boxrule=0pt,bottomrule=0.5pt,toprule=0.5pt, toprule at break =
+ 0pt, bottomrule at break = 0pt,]
+ \itshape
+ This package is in beta version---do not hesitate to report bugs, as well as requests for improvement.
+\end{tcolorbox}
+
+\section{Installation}
+
+\mpneural is on \ctan{} and can also be installed via the package manager of your
+distribution.
+
+\begin{center}
+ \url{https://www.ctan.org/pkg/mp-neuralnetwork}
+\end{center}
+
+
+\subsection{With \TeX live under Linux or macOS}
+
+To install \mpneural with \TeX Live, you will have to create the directory
+\lstinline+texmf+ in your \lstinline+home+.
+
+\begin{commandshell}
+mkdir ~/texmf
+\end{commandshell}
+
+Then, you will have to place the \lstinline+neuralnetwork.mp+ and
+\lstinline+metaobj-patch.mp+\footnote{Thanks to Denis Roegel, this file define a
+\texttt{Group} object to group different \MO/ objects.
+} files in
+\begin{center}
+ \lstinline+~/texmf/metapost/mp-neuralnetwork/+
+\end{center}
+
+
+Once this is done, \mpneural will be loaded with the classic \MP{}
+input code
+\begin{mpcode}
+input mp-neuralnetwork
+\end{mpcode}
+
+\subsection{With Mik\TeX{} and Windows}
+
+These two systems are unknown to the author of \mpneural, so we
+refer you to the Mik\TeX documentation concerning the addition of local packages:
+\begin{center}
+ \url{http://docs.miktex.org/manual/localadditions.html}
+\end{center}
+
+
+
+\subsection{Dependencies}
+
+
+\mpneural depends:
+\begin{itemize}
+\item of course on \MP~\cite{ctan-metapost};
+\item on the package\package{metaobj}~\cite{ctan-metaobj};
+\item if \mpneural is not used with
+\hologo{LuaLaTeX} and the \package{luamplib} package, on the \package{latexmp}
+package\cite{ctan-latexmp};
+\item and on the package \package{colorbrewer-rgb}~\cite{ctan-metapost-colorbrewer}.
+\end{itemize}
+\section{Main Command}
+
+The package \mpneural provides one principal command that has two possible
+invocations.
+
+\subsection{Finite network}
+
+\commande|drawANN(«name1»,«size1»,«name2»,«size2», etc.)|\smallskip\index{drawANN@\lstinline+drawANN+}
+
+Each layer of the network is described by a couple \meta{name} and \meta{size}, where:
+\begin{description}
+ \item[\meta{name}:] is the names of the layers. It a
+ string, and this is the prefix of each node (for instance \lstinline+"x"+ will
+ produce nodes $x_i$).
+ \item[\meta{size}:] is the size (integer) of the layer (for instance if
+ \meta{size}$=4$, the layer will be composed by nodes $x_1$, $x_2$, $x_3$ and $x_4$).
+\end{description}
+Here, a simple example.
+\begin{ExempleMP}
+input mp-neuralnetwork
+
+beginfig(1);
+drawANN("x",4,"y",5,"z",1);
+endfig;
+\end{ExempleMP}
+
+
+\subsection{Abstract network}
+
+You can set variables for the size of each layers with the same command using
+the string notation for the size instead of an integer.
+
+\commande|drawANN(«name1»,«size1»,«name2»,«size2», etc.)|\smallskip\index{drawANN@\lstinline+drawANN+}
+
+Each layer of the network is described by a couple \meta{name} and \meta{size}, where:
+\begin{description}
+ \item[\meta{name}:] is the names of the layers. It a
+ string, and this is the prefix of each node (for instance \lstinline+"x"+ will
+ produce nodes $x_i$).
+ \item[\meta{size}:] is the notation for size (string) of the layer (for instance
+ \lstinline+"p"+, the layer will be composed by nodes $x_1$, $x_2$, $\dots$ and $x_p$).
+\end{description}
+Here, a simple example.
+\begin{ExempleMP}
+input mp-neuralnetwork
+
+beginfig(1);
+drawANN("x","m","y","n","z","p");
+endfig;
+\end{ExempleMP}
+
+The first and the last layers are composed with four nodes, and intern layers
+with five nodes.
+
+\section{Options}
+
+\mpneural allows to customize the network representation. If you want to restore
+default behaviour, you can use the following command.
+\commande|mpneural_init_values|\smallskip\index{mpneural_init_values@\lstinline+mpneural_init_values+}
+
+
+\subsection{Colors}
+
+We can see, in the previous examples, that the nodes are colored. If you do not
+want them to be colored, use the following command.
+
+\commande|colored_layers(«boolean»)|\smallskip\index{colored_layers@\lstinline+colored_layers+}
+
+\begin{description}
+ \item[\meta{boolean}:] is a \MP{} boolean (true by default) to choose if we
+ want or not colored layers.
+\end{description}
+
+If the layers are colored, \mpneural{} uses \lstinline+Spectral+ colors defined
+in \package{colorbrewer-rgb}\footnote{Up to 11 colors. If there are more layers,
+the colors cycle.}.
+
+You can also define colors for each layer using the following command.
+
+
+\commande|set_layer_colors(«layer number1»,«color1»,«layer number 1»,«color1»,etc.)|\smallskip\index{set_layer_colors@\lstinline+set_layer_colors+}
+
+\begin{description}
+ \item[\meta{layer number 1}, \meta{color1}:] is a couple with the integer of
+ the layer we want to color with \meta{color1}.
+\end{description}
+
+The rest of layers are set to white by default.
+
+For example:
+\begin{ExempleMP}
+input mp-neuralnetwork
+
+colored_layers(false);
+beginfig(1);
+drawANN("x",5,"y",1);
+endfig;
+\end{ExempleMP}
+
+and
+\begin{ExempleMP}
+input mp-neuralnetwork
+
+colored_layers(true);
+set_layer_colors(1,red,3,(0.7,0.7,0.7));
+
+beginfig(1);
+drawANN("x",5,"y",1,"z",4);
+endfig;
+\end{ExempleMP}
+
+Connections are colored. The default color is gray (\lstinline+0.4*white+) but
+you can modify that with the following command.
+
+\commande|set_connection_color(«color»)|\smallskip\index{set_connection_color@\lstinline+set_connection_color+}
+
+\begin{description}
+ \item[\meta{color}:] is the color for drawing the connections between layers
+ (default \lstinline+0.4*white+).
+\end{description}
+
+
+\subsection{Annotations}
+
+\mpneural provides some tools to annotate the network. However, because we use
+\MO/ behind the scene, you can always use \MO/ tools to draw above the graph
+build with \mpneural (see section~\ref{sec:mo}).
+
+\subsubsection{Frames}
+
+You can add frames around three different blocks: input, output and hidden
+layers.
+
+To draw a frame around these three types of layers (or stop the drawing of theses frames), you
+can use the following commands.
+
+
+\commande|framed_input(«boolean»)|\smallskip\index{framed_input@\lstinline+framed_input+}
+
+
+\commande|framed_output(«boolean»)|\smallskip\index{framed_output@\lstinline+framed_output+}
+
+
+\commande|framed_hidden(«boolean»)|\smallskip\index{framed_hidden@\lstinline+framed_hidden+}
+\begin{description}
+ \item[\meta{boolean}:] true or false (default).
+\end{description}
+
+\subsubsection{Positioning nodes}
+
+We can adjust the vertical and horizontal distance between nodes with the
+following commands.
+
+\commande|set_vspace(«distance»)|\smallskip\index{set_vspace@\lstinline+set_vspace+}
+
+\begin{description}
+ \item[\meta{distance}:] is a numeric (default \lstinline+1.5cm+).
+\end{description}
+
+
+\commande|set_hspace(«distance»)|\smallskip\index{set_hspace@\lstinline+set_hspace+}
+
+\begin{description}
+ \item[\meta{distance}:] is a numeric (default \lstinline+2.2cm+).
+\end{description}
+
+\begin{ExempleMP}
+input mp-neuralnetwork
+
+beginfig(1);
+set_vspace(2cm);
+set_hspace(3cm);
+drawANN("x",5,"u",6,"v",3,"y",2);
+endfig;
+\end{ExempleMP}
+
+\subsubsection{Labels and sections}
+
+
+First, if you do not want to label the nodes, use the following command to
+deactivate the function.
+
+\commande|show_node_labels(«boolean»)|\smallskip\index{show_node_labels@\lstinline+show_node_labels+}
+
+You can also add legends to these part of the network (independently of the
+frame draw). For that, you can use the following command.
+
+\commande|print_legends(«boolean»)|\smallskip\index{print_legends@\lstinline+print_legends+}
+\begin{description}
+ \item[\meta{boolean}:] true or false (default).
+\end{description}
+
+The default value for the legends of the three parts (input, output, and
+hidden), are \lstinline+"Input layer"+, \lstinline+"Output layer"+, and
+\lstinline+"Hidden layer(s)"+. You can modify these string with the following
+commands.
+
+
+\commande|set_input_legend(«string»)|\smallskip\index{set_input_legend@\lstinline+set_input_legend+}
+
+\commande|set_output_legend(«string»)|\smallskip\index{set_output_legend@\lstinline+set_output_legend+}
+
+\commande|set_hidden_legend(«string»)|\smallskip\index{set_hidden_legend@\lstinline+set_hidden_legend+}
+
+
+\begin{description}
+ \item[\meta{string}:] is a string for the legend (default are \lstinline+"Input layer"+, \lstinline+"Output layer"+, and
+ \lstinline+"Hidden layer(s)"+).
+\end{description}
+
+
+\begin{ExempleMP}
+input mp-neuralnetwork
+
+colored_layers(false);
+beginfig(1);
+print_legends(true);
+set_input_legend("Entrées");
+set_output_legend("Sortie");
+framed_hidden(true);
+drawANN("x",5,"u",6,"v",8,"y",2);
+endfig;
+\end{ExempleMP}
+
+You may also want to print the \emph{weights} on the network. To do that, use
+the following commands.
+\commande|print_weights(«boolean»)|\smallskip\index{print_weights@\lstinline+print_weights+}
+
+By default, weights are denoted by $w$, but you can change that with the
+following command.
+
+
+\commande|set_weights_notation(«string»)|\smallskip\index{set_weights_notation@\lstinline+set_weights_notation+}
+\begin{description}
+ \item[\meta{string}:] is a string for the weights (default is
+ \lstinline+"w"+).
+ This is a prefix: for instance, with the default value, the weights are, in
+ math mode, $w_{ij}^{(k)}$ for the $k$-th layer.
+\end{description}
+
+
+
+\begin{ExempleMP}
+input mp-neuralnetwork
+
+colored_layers(false);
+beginfig(1);
+print_legends(false);
+print_weights(true);
+drawANN("x",4,"u",6,"v",5,"y",2);
+endfig;
+\end{ExempleMP}
+
+You can add labels positioning them with relative coordinates that is $(0,0)$ at
+bottom left of the bounding box of the complete graph and $(1,1)$ at top right.
+For that, you can use the following command.
+
+\commande|labelANN(«string»)(«xpart»,«ypart») «\MO/ options»|\smallskip\index{labelANN@\lstinline+labelANN+}
+\begin{description}
+ \item[\meta{string}:] is a string for the label (process by
+ \lstinline+textext+ command).
+ \item[\meta{xpart},\meta{ypart}:] are numeric in the relative coordinates (but
+ can be lower or greater than 0 and 1.).
+\end{description}
+
+This command build a \MO/ box. It is the center of the box that is put at the
+relative coordinate. Moreover, you can add the \MO/ options at the end to
+customize the box.
+
+\begin{ExempleMP}
+input mp-neuralnetwork
+
+colored_layers(false);
+beginfig(1);
+print_legends(false);
+print_weights(true);
+drawANN("x",4,"u",6,"v",5,"y",2);
+labelANN("My fabulous network")(0.5,-0.2) "filled(true)","fillcolor((0.8,0.5,0.5))";
+endfig;
+\end{ExempleMP}
+
+
+
+
+\section{With MetaObj}\label{sec:mo}
+
+Because \mpneural is built above \MO/~\cite{ctan-metaobj}, the tools of the
+incredible package are available.
+
+The nodes of the network are \MO/ boxes, with names:
+\begin{itemize}
+\item with the prefix \texttt{ANN};
+\item the instance number of the network (useful if you draw
+multiple networks);
+\item an underscore \texttt{\_};
+\item the identifier of the layer (specified in the \lstinline+drawANN+ command);
+\item the number of the node in the layer.
+\end{itemize}
+
+The boxes of weights are named as follows:
+\begin{itemize}
+\item with the prefix \texttt{ANN};
+\item the instance number of the network (useful if you draw
+multiple networks);
+\item an underscore \texttt{\_};
+\item \texttt{weights};
+\item the number of the left layer.
+\end{itemize}
+
+The boxes of label for input, output and hidden layers are named as follows:
+\begin{itemize}
+\item with the prefix \texttt{ANN};
+\item the instance number of the network (useful if you draw
+multiple networks);
+\item an underscore \texttt{\_};
+\item \texttt{input}, \texttt{output} or \texttt{hidden}.
+\end{itemize}
+
+
+
+
+Labels generated by \lstinline+labelANN+ are also \MO/ boxes named as follows:
+\begin{itemize}
+\item with the prefix \texttt{ANN};
+\item the instance number of the network (useful if you draw
+multiple networks);
+\item an underscore \texttt{\_};
+\item \texttt{label};
+\item then the number of the label.
+\end{itemize}
+
+For example, if you draw the following network:
+\begin{mpcode}
+input mp-neuralnetwork
+
+beginfig(1);
+drawANN("x",3,"y",2);
+endfig;
+\end{mpcode}
+
+The nodes will be named \texttt{ANN1\_x1}, \texttt{ANN1\_x2}, \texttt{ANN1\_x3},
+\texttt{ANN1\_y1}, and \texttt{ANN1\_y2}. The weights will be named
+\texttt{ANN1\_weights1}.
+
+Here is a real example (this is the 10th instance of a network drawing in this
+document). \lstinline+ncline+ is a \MO/ command.
+\begin{ExempleMP}
+input mp-neuralnetwork;
+
+beginfig(1);
+ print_legends(true);
+ show_node_labels(true);
+ drawANN("x","n","a","p","b","q","y","m") "circmargin(3pt)";
+ labelANN("Test")(1.3,0.4);
+ labelANN("Test")(0.5,1.1) "framed(false)";
+ ncline(ANN10_label2)(ANN10_x2)"doubleline(true)","coilwidth(2mm)",
+ "angleA(0)",
+ "linewidth(1pt)";
+endfig;
+\end{ExempleMP}
+
+
+\printbibliography
+\printindex
+\end{document}
Property changes on: trunk/Master/texmf-dist/doc/metapost/mp-neuralnetwork/mp-neuralnetwork-doc-en.tex
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/doc/metapost/mp-neuralnetwork/mp-neuralnetwork-preamble.tex
===================================================================
--- trunk/Master/texmf-dist/doc/metapost/mp-neuralnetwork/mp-neuralnetwork-preamble.tex (rev 0)
+++ trunk/Master/texmf-dist/doc/metapost/mp-neuralnetwork/mp-neuralnetwork-preamble.tex 2025-01-28 21:09:25 UTC (rev 73627)
@@ -0,0 +1,188 @@
+\usepackage{tcolorbox}
+\tcbuselibrary{listings,breakable}
+%\tcbuselibrary{documentation}
+\usepackage{enumitem}
+\usepackage[tikz]{bclogo}
+\usepackage{mflogo}
+\usepackage{hologo}
+\usepackage{luamplib}
+\mplibtextextlabel{enable}
+\usepackage{biblatex}
+\addbibresource{ctan.bib}
+\usepackage{wrapfig}
+\usepackage{accsupp}
+\usepackage{siunitx}
+\usepackage{imakeidx}
+%\usepackage{csquotes}
+\usepackage{fancyvrb,xparse,xargs}
+\usepackage[sfdefault]{FiraSans}
+\usepackage[mathrm=sym]{firamath-otf}
+\setmonofont{Fira Mono}
+%\setmonofont{FiraCode-Regular.ttf}[BoldFont= FiraCode-Bold.ttf,ItalicFont= FiraCode-RegularItalic.otf,BoldItalicFont= FiraCode-BoldItalic.otf,Ligatures={NoCommon, NoDiscretionary, NoHistoric, NoRequired, NoContextual}]
+
+\usepackage{xspace}
+\usepackage{animate}
+\newcommand{\ctan}{\textsc{ctan}}
+\NewDocumentCommand{\package}{ m }{%
+ \href{https://ctan.org/pkg/#1}{#1}\xspace
+}
+
+\definecolor{darkred}{rgb}{0.6,0.1,0.1}
+\definecolor{vert}{rgb}{0.1,0.4,0.1}
+\definecolor{bleu}{rgb}{0.2,0.2,0.6}
+\definecolor{orange}{rgb}{0.6,0.4,0.}
+\colorlet{code}{blue!80!black}
+
+\usepackage[colorlinks=true,urlcolor=orange,linkcolor=orange,menucolor=black,citecolor=orange]{hyperref}
+
+\newcommand \file {\nolinkurl}
+\renewcommand \cmd {\texttt}
+\renewcommand \code [1] {\texorpdfstring {\texttt{\color{code}#1}} {#1}}
+\renewcommand*\cs [1] {\code{\textbackslash #1}}
+
+
+
+\newcommand*\commande{\par\bigskip\noindent\hspace{-30pt}%
+ \SaveVerb[aftersave={%
+ \UseVerb{Vitem}%
+ }%
+ ]{Vitem}%
+ }
+ \newcommand\vitem[1][]{\SaveVerb[%
+ aftersave={\item[\textnormal{\UseVerb[#1]{vsave}}]}]{vsave}}
+\newcommand*\textme[1]{\textcolor{black}{\rmfamily\textit{#1}}}
+%\renewcommand*\meta[1]{% % meta
+% \textme{\ensuremath{\langle}#1\ensuremath{\rangle}}}
+\newcommand*\optstar{% % optional star
+ \meta{\ensuremath{*}}\xspace}
+\DefineShortVerb{\|}
+\newcommand\R{\mathbf{R}}
+\setlength{\fboxsep}{2pt}
+\fvset{%
+ codes={\catcode`\«\active \catcode`\×\active },
+ defineactive={\makefancyog\makefancytimes},
+ formatcom=\color{darkred},
+ frame=single
+}
+% rendre «...» équivalent à \meta{...}
+{\catcode`\«\active
+ \newcommandx\makefancyog[0][addprefix=\global]{%
+ \def«##1»{\meta{##1}}}}
+% rendre × équivalent à \optstar
+{\catcode`\×\active
+ \newcommandx\makefancytimes[0][addprefix=\global]{%
+ \def×{\optstar{}}}}
+
+
+\newcommand\mpneural{\texttt{mp-neuralnetwork}\xspace}
+\usepackage{fetamont}
+\def\MO/{\textffm{META\-OBJ}}
+
+%\addbibresource{biblio.bib}
+
+
+\lstset{
+ numberstyle=\footnotesize\color{vert},
+ keywordstyle=\ttfamily\bfseries\color{bleu},
+ basicstyle=\ttfamily,
+ commentstyle=\itshape\color{vert},
+ stringstyle=\ttfamily\color{orange},
+ showstringspaces=false,
+ language=MetaPost,
+ breaklines=true,
+ breakindent=30pt,
+ defaultdialect=MetaPost,
+ classoffset=1,% frame=tb
+ morekeywords={colored_layers,
+ print_weights,
+ drawANN,
+ set_connection_color,
+ set_hidden_legend,
+ set_hspace,
+ set_input_legend,
+ set_layer_colors,
+ set_output_legend,
+ set_vspace,
+ set_weights_notation,
+ show_node_labels,
+ framed_hidden,
+ framed_input,
+ framed_output,
+ labelANN,
+ mpneural_init_values,
+ print_legends, },
+ keywordstyle=\color{darkred},
+ classoffset=2,% frame=tb
+ morekeywords={},
+ keywordstyle=\color{vert},
+ classoffset=0,% frame=tb
+ morekeywords={ncline},
+ keywordstyle=\color{bleu}
+}
+
+
+\extractcolorspecs{darkred!3}\modelcmd\colorcmd
+\makeatletter
+\tcbset{%
+ listing metapost/.code={%
+ \def\tcbuselistingtext at input{\begin{mplibcode}[mpneural] verbatimtex
+ \leavevmode etex;input mp-neuralnetwork;mpneural_init_values;background:=(\colorcmd); input \jobname.listing;
+ \end{mplibcode}}%
+ }
+}
+\makeatother
+\newtcblisting[auto counter,]{ExempleMP}[1][]{%
+ arc=0pt,outer arc=0pt,
+ colback=darkred!3,
+ colframe=darkred,
+ breakable,fontupper=\small,
+ boxsep=0pt,left=5pt,right=5pt,top=5pt,bottom=5pt, bottomtitle =
+ 3pt, toptitle=3pt,
+ boxrule=0pt,bottomrule=0.5pt,toprule=0.5pt, toprule at break =
+ 0pt, bottomrule at break = 0pt,
+ %listing side text,
+ listing metapost,
+ title=Exemple~\thetcbcounter,
+ listing options={breaklines},#1
+}
+
+\newtcblisting{commandshell}{colback=black,colupper=white,colframe=black,
+ arc=0pt,
+ listing only,boxsep=0pt,listing
+ options={style=tcblatex,language=sh},
+ every listing line={\BeginAccSupp{ActualText={}}\textcolor{red}{\small\ttfamily\bfseries user \$> }}\EndAccSupp{}}
+
+
+ \newtcblisting{mpcode}[1][]{
+ arc=0pt,outer arc=0pt,
+ colback=darkred!3,
+ colframe=darkred,
+ breakable,
+ boxsep=0pt,left=5pt,right=5pt,top=5pt,bottom=5pt, bottomtitle =
+ 3pt, toptitle=3pt,
+ boxrule=0pt,bottomrule=0.5pt,toprule=0.5pt, toprule at break =
+ 0pt, bottomrule at break = 0pt,
+ listing only,boxsep=0pt,listing
+ options={breaklines},#1
+}
+
+\newtcblisting{latexcode}{
+ arc=0pt,outer arc=0pt,
+ colback=darkred!3,
+ colframe=darkred,
+ breakable,
+ boxsep=0pt,left=5pt,right=5pt,top=5pt,bottom=5pt, bottomtitle =
+ 3pt, toptitle=3pt,
+ boxrule=0pt,bottomrule=0.5pt,toprule=0.5pt, toprule at break =
+ 0pt, bottomrule at break = 0pt,
+ listing only,boxsep=0pt,listing
+ options={breaklines,language={[LaTeX]TeX}}
+}
+
+
+\newcommand\pdf{\textsc{pdf}}
+
+\usepackage{array,booktabs}
+\usepackage{collcell}
+
+\newcolumntype{H}{>{\collectcell\lstinline}l<{\endcollectcell}}
\ No newline at end of file
Property changes on: trunk/Master/texmf-dist/doc/metapost/mp-neuralnetwork/mp-neuralnetwork-preamble.tex
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/metapost/mp-neuralnetwork/mp-neuralnetwork-metaobj-patch.mp
===================================================================
--- trunk/Master/texmf-dist/metapost/mp-neuralnetwork/mp-neuralnetwork-metaobj-patch.mp (rev 0)
+++ trunk/Master/texmf-dist/metapost/mp-neuralnetwork/mp-neuralnetwork-metaobj-patch.mp 2025-01-28 21:09:25 UTC (rev 73627)
@@ -0,0 +1,74 @@
+%=====================================================================
+% |Group| class (DR, 4 December 2024, after idea by Maximum Chupin)
+% based on the |HBox| class
+
+% |Group|: Generic Group
+% |@#| is a name for an object (must be a suffix)
+% |@#| will be the number of the object, but will also be used
+% as a prefix for other variables.
+vardef newGroup@#(text sublist) text options =
+ ExecuteOptions(@#)(options);
+ assignObj(@#,"Group");
+ StandardInterface;
+ save n,i,eq;numeric n,i;string eq;
+ n=0;
+ forsuffixes $:=sublist:n:=n+1;endfor;
+ ObjSubArray(sb)(n); % |n| is the number of elements
+ ObjNumeric nst,leftmax,rightmax,botmax,topmax;
+ setNumeric(nst)(n);
+ i=0;
+ forsuffixes $:=sublist:i:=i+1;
+ SubObjectOfArray(sb[i],$);
+ endfor;
+ setMaxBB@#;
+ % we now build the equations:
+ % horizontal equation: horizontal space at left and right
+ eq="xpart(obj(@#sb[@#leftmax]).w-@#w)" &
+ "=xpart(@#e-obj(@#sb[@#rightmax]).e)=" &
+ decimal(OptionValue@#("dx")) & ";";
+ % vertical equation: vertical space at top and bottom
+ eq:= eq & "ypart(obj(@#sb[@#botmax]).s-@#s)" &
+ "=ypart(@#n-obj(@#sb[@#topmax]).n)=" &
+ decimal(OptionValue@#("dy")) & ";";
+ ObjCode StandardEquations,eq;
+ StandardTies;
+enddef;
+
+vardef setMaxBB@#=
+ @#leftmax:=1; % initialization of indexes
+ @#rightmax:=1;
+ @#botmax:=1;
+ @#topmax:=1;
+ for i:=2 upto @#nst:
+ if xpart(obj(@#sb[i]).w-obj(@#sb[@#leftmax]).w)<0:@#leftmax:=i;fi;
+ if xpart(obj(@#sb[i]).e-obj(@#sb[@#rightmax]).e)>0:@#rightmax:=i;fi;
+ if ypart(obj(@#sb[i]).s-obj(@#sb[@#botmax]).s)<0:@#botmax:=i;fi;
+ if ypart(obj(@#sb[i]).n-obj(@#sb[@#topmax]).n)>0:@#topmax:=i;fi;
+ endfor;
+enddef;
+
+streamline("Group")("(text sublist)","suffixlist(sublist)");
+
+def BpathGroup(suffix n)= StandardBpath(n) enddef;
+
+def drawGroup(suffix n)=
+ drawFramedOrFilledObject_(n);
+ drawObjArray(n)(sb);
+ drawMemorizedPaths_(n);
+enddef;
+
+% Default values of |Group|:
+setObjectDefaultOption("Group")("dx")(0mm);
+setObjectDefaultOption("Group")("dy")(0mm);
+setObjectDefaultOption("Group")("framed")(false);
+setObjectDefaultOption("Group")("filled")(false);
+setObjectDefaultOption("Group")("fillcolor")(black);
+setObjectDefaultOption("Group")("framewidth")(.5bp);
+setObjectDefaultOption("Group")("framecolor")(black);
+setObjectDefaultOption("Group")("framestyle")("");
+setObjectDefaultOption("Group")("shadow")(false); % no shadow by default
+setObjectDefaultOption("Group")("shadowcolor")(black);
+%---------------------------------------------------------------------------
+
+
+endinput
\ No newline at end of file
Property changes on: trunk/Master/texmf-dist/metapost/mp-neuralnetwork/mp-neuralnetwork-metaobj-patch.mp
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/metapost/mp-neuralnetwork/mp-neuralnetwork.mp
===================================================================
--- trunk/Master/texmf-dist/metapost/mp-neuralnetwork/mp-neuralnetwork.mp (rev 0)
+++ trunk/Master/texmf-dist/metapost/mp-neuralnetwork/mp-neuralnetwork.mp 2025-01-28 21:09:25 UTC (rev 73627)
@@ -0,0 +1,361 @@
+% Don't load this package twice:
+if known neuralnetwork_version: expandafter endinput; fi;
+
+numeric neuralnetwork_version;string neuralnetwork_date;
+neuralnetwork_version=0.1;
+neuralnetwork_date="2025/01/27";
+% The banner:
+message "******* mp-neuralnetwork " & decimal (neuralnetwork_version) &
+ " (c) Maxime Chupin (" & neuralnetwork_date & ") *******";message "";
+
+input metaobj;
+input mp-neuralnetwork-metaobj-patch;
+if not known mplib: input latexmp fi;
+input colorbrewer-rgb;
+
+interim ahangle := 40;
+interim ahlength := 2;
+
+numeric _ANN_Vspace,_ANN_Hspace;
+_ANN_Vspace:=1.5cm;
+_ANN_Hspace:=2.2cm;
+
+
+
+boolean
+_ANN_Hidden_b,_ANN_Input_b,_ANN_Output_b,_ANN_Legends_b,_ANN_show_node_labels_b,_ANN_weights_b,_ANN_abstract_b,_ANN_Legends_b,_ANN_colored_b,_ANN_user_color;
+
+string _ANN_input_legend,_ANN_output_legend, _ANN_hidden_legend;
+string _ANN_weights;
+
+numeric _ANN_instance_nbr;
+numeric _ANN_label_nbr;
+color _ANN_colors[],_ANN_connect_color;
+
+
+
+% init of colors
+for ii:=0 upto 30:
+ _ANN_colors[ii]:=white;
+endfor;
+
+_ANN_connect_color := 0.4*white;
+
+_ANN_input_legend := "Input layer";
+_ANN_output_legend := "Output layer";
+_ANN_hidden_legend := "Hidden layer(s)";
+
+_ANN_colored_b := true;
+_ANN_Legends_b:=false;
+_ANN_abstract_b:=false;
+_ANN_Hidden_b := false;
+_ANN_Input_b := false;
+_ANN_Output_b := false;
+_ANN_show_node_labels_b := true;
+_ANN_weights_b := false;
+_ANN_user_color:=false;
+_ANN_weights := "w";
+
+def mpneural_init_values=
+ _ANN_Vspace:=1.5cm;
+ _ANN_Hspace:=2.2cm;
+ _ANN_input_legend := "Input layer";
+ _ANN_output_legend := "Output layer";
+ _ANN_hidden_legend := "Hidden layer(s)";
+
+ _ANN_colored_b := true;
+ _ANN_Legends_b:=false;
+ _ANN_abstract_b:=false;
+ _ANN_Hidden_b := false;
+ _ANN_Input_b := false;
+ _ANN_Output_b := false;
+ _ANN_show_node_labels_b := true;
+ _ANN_weights_b := false;
+ _ANN_user_color:=false;
+ _ANN_weights := "w";
+ _ANN_connect_color := 0.4*white;
+enddef;
+
+
+
+
+def set_vspace(expr d)=
+ _ANN_Vspace:=d;
+enddef;
+
+def set_hspace(expr d)=
+ _ANN_Hspace:=d;
+enddef;
+def set_connection_color(expr c)=
+ _ANN_connect_color:=c;
+enddef;
+
+
+def show_node_labels(expr b)=
+ _ANN_show_node_labels_b:=b;
+enddef;
+
+def framed_input(expr b)=
+ _ANN_Input_b:=b;
+enddef;
+
+def framed_output(expr b)=
+ _ANN_Output_b:=b;
+enddef;
+
+def framed_hidden(expr b)=
+ _ANN_Hidden_b:=b;
+enddef;
+
+def print_legends(expr b)=
+ _ANN_Legends_b:=b;
+enddef;
+
+def colored_layers(expr b)=
+ _ANN_colored_b:=b;
+enddef;
+
+vardef set_layer_colors(text t)=
+ save ii,_i_layer;
+ % initialisation
+ % init of colors
+ for ii:=1 upto 30:
+ _ANN_colors[ii]:=(1,1,1);
+ endfor;
+ for c=t:
+ show(c);
+ if(numeric c):
+ _i_layer:=c;
+ elseif(color c):
+ _ANN_colors[_i_layer]:=c;
+ fi
+ endfor;
+ _ANN_user_color:=true;
+enddef;
+
+def print_weights(expr b)=
+ _ANN_weights_b:=b;
+enddef;
+
+def set_weights_notation(expr s)=
+ _ANN_weights:=s;
+enddef;
+
+
+def set_input_legend(expr s)=
+ _ANN_input_legend := s;
+enddef;
+
+def set_output_legend(expr s)=
+ _ANN_output_legend := s;
+enddef;
+
+def set_hidden_legend(expr s)=
+ _ANN_hidden_legend := s;
+enddef;
+
+
+_ANN_instance_nbr :=0;
+
+def drawANN(text t) text options=
+ % t : list of ("str1",int1,"str2",int2, etc.)
+
+ save prefixANN,_ANN_i,_ANN_i_couple,_ANN_n,_ANN_lb,_ANN_lb_int;
+ string prefixANN;
+
+ numeric _ANN_n[],_ANN_i,_ANN_i_couple;
+ string _ANN_lb[],_ANN_lb_int[];
+
+ _ANN_instance_nbr := _ANN_instance_nbr+1;
+
+ prefixANN:="ANN"&decimal(_ANN_instance_nbr);
+ _ANN_abstract_b:=false;
+ _ANN_i:=1;
+ _ANN_i_couple:=1;
+ % parsing the list
+ for x=t:
+ if(odd _ANN_i):
+ _ANN_lb[_ANN_i_couple]:=prefixANN&"_"&x;
+ else:
+ if(numeric x):
+ _ANN_n[_ANN_i_couple]:=x;
+ _ANN_i_couple:=_ANN_i_couple+1;
+ else:
+ _ANN_abstract_b:=true;
+ _ANN_n[_ANN_i_couple]:=5;
+ _ANN_lb_int[_ANN_i_couple]:=x;
+ _ANN_i_couple:=_ANN_i_couple+1;
+ fi
+ fi
+ _ANN_i:=_ANN_i+1;
+ endfor
+
+ % colors
+ if(_ANN_user_color=false):
+ for i:=1 upto _ANN_i_couple-1:
+ _ANN_colors[i]:=Spectral[min(11,_ANN_i_couple-1)][i mod 11];
+ endfor
+ fi
+
+ if(_ANN_abstract_b=true): % small size for input and output
+ _ANN_n[1]:=4;
+ _ANN_n[_ANN_i_couple-1]:=4;
+ fi
+ for i:=1 upto _ANN_i_couple -1:
+ for j:=1 upto _ANN_n[i]:
+ if( not _ANN_show_node_labels_b):
+ newCircle.scantokens(_ANN_lb[i])[j](textext("$\phantom{a}$"))
+ if(_ANN_colored_b): "filled(true)","fillcolor("&str _ANN_colors[i] &")", fi options;
+ elseif(_ANN_abstract_b): % abstract
+
+ if(j<3): % for the two first ones
+ newCircle.scantokens(_ANN_lb[i])[j](textext("$"&substring
+ (4+length(decimal(_ANN_instance_nbr)),length _ANN_lb[i]) of
+ _ANN_lb[i]&"_{"&decimal(j)&"}$")) if(_ANN_colored_b): "filled(true)","fillcolor("&str _ANN_colors[i] &")", fi options;
+ elseif(j=3): % dots
+ newBox.scantokens(_ANN_lb[i])[j](image(drawoptions(withpen
+ pencircle scaled 1bp);drawdot (0,0);drawdot
+ (0,0.1cm);drawdot
+ (0,0.2cm);drawoptions();)) if(_ANN_colored_b):
+ "filled(true)","fillcolor("&str _ANN_colors[i] &")", fi ;
+ else: % lasts
+
+ if((i=1) or (i=_ANN_i_couple-1)): %if input or output only last
+ newCircle.scantokens(_ANN_lb[i])[j](textext("$"&substring
+ (4+length(decimal(_ANN_instance_nbr)),length _ANN_lb[i]) of
+ _ANN_lb[i]&"_{"&_ANN_lb_int[i]&"}$")) if(_ANN_colored_b): "filled(true)","fillcolor("&str _ANN_colors[i] &")", fi options;
+ else:
+ if(j=4):
+ newBox.scantokens(_ANN_lb[i])[j](image(drawoptions(withpen
+ pencircle scaled 1bp);drawdot (0,0);drawdot
+ (0,0.1cm);drawdot (0,0.2cm);drawoptions();)) if(_ANN_colored_b): "filled(true)","fillcolor("&str _ANN_colors[i] &")", fi ;
+ else:
+ newCircle.scantokens(_ANN_lb[i])[j](textext("$"&substring
+ (4+length(decimal(_ANN_instance_nbr)),length _ANN_lb[i]) of
+ _ANN_lb[i]&"_{"&_ANN_lb_int[i]&"}$")) if(_ANN_colored_b): "filled(true)","fillcolor("&str _ANN_colors[i] &")", fi options;
+ fi
+ fi
+ fi
+ else:
+ newCircle.scantokens(_ANN_lb[i])[j](textext("$"&substring
+ (4+length(decimal(_ANN_instance_nbr)),length _ANN_lb[i]) of
+ _ANN_lb[i]&"_{"&decimal(j)&"}$")) if(_ANN_colored_b):
+ "filled(true)","fillcolor("&str _ANN_colors[i] &")", fi options;
+ fi
+ if(j=1):
+ if(i=1):
+ scantokens(_ANN_lb[i])[j].c = origin;
+ else:
+ scantokens(_ANN_lb[i])[j].c = scantokens(_ANN_lb[i-1])[j].c+(_ANN_Hspace,0)+(0,-(_ANN_n[i]-_ANN_n[i-1])/3.5*_ANN_Vspace);
+ fi
+ else:
+ scantokens(_ANN_lb[i])[j].n-scantokens(_ANN_lb[i])[j-1].s=(0,_ANN_Vspace);
+ fi
+ endfor
+ for j:=1 upto _ANN_n[i]:
+ drawObj(scantokens(_ANN_lb[i])[j]);
+ endfor
+ endfor
+ % group for hiddenlayer
+
+ if(_ANN_i_couple-1>3):
+ newGroup.scantokens(prefixANN)_hidden( for i:=2 upto (_ANN_i_couple-2): for j:=1 upto _ANN_n[i]:
+ scantokens(_ANN_lb[i])[j] if((i<_ANN_i_couple-2)or(j<_ANN_n[i])): , fi
+ endfor endfor) "framed(true)","dx(3pt)","dy(3pt)";
+ fi
+ if(_ANN_Hidden_b):
+ drawObj(scantokens(prefixANN)_hidden) ;
+ fi
+ % rectangle for inputlayer
+
+ if(_ANN_n[1]>1):
+ newGroup.scantokens(prefixANN)_input(for j:=1 upto _ANN_n[1]:
+ scantokens(_ANN_lb[1])[j] if(j<_ANN_n[1]): , fi
+ endfor)
+ "framed(true)","dx(3pt)","dy(3pt)";
+ else:
+ newBox.scantokens(prefixANN)_input(scantokens(_ANN_lb[1])[1]) "filled(false)","framed(true)","dx(3pt)","dy(3pt)";
+ fi
+ if(_ANN_Input_b):
+ drawObj(scantokens(prefixANN)_input);
+ fi
+
+ % rectangle for outputlayer
+
+ if(_ANN_n[_ANN_i_couple-1]>1):
+ newGroup.scantokens(prefixANN)_output(for j:=1 upto _ANN_n[_ANN_i_couple-1]:
+ scantokens(_ANN_lb[_ANN_i_couple-1])[j] if(j<_ANN_n[_ANN_i_couple-1]): , fi
+ endfor)
+ "framed(true)","dx(3pt)","dy(3pt)";
+ else:
+ newBox.scantokens(prefixANN)_output(scantokens(_ANN_lb[_ANN_i_couple-1])[1]) "filled(false)","framed(true)","dx(3pt)","dy(3pt)";
+ fi
+ if(_ANN_Output_b):
+ drawObj(scantokens(prefixANN)_output);
+ fi
+
+ % links
+ for i:=1 upto _ANN_i_couple-1:
+ if(i>1):
+ for j:=1 upto _ANN_n[i-1]:
+ for k:=1 upto _ANN_n[i]:
+ ncline(scantokens(_ANN_lb[i-1])[j])(scantokens(_ANN_lb[i])[k])
+ "linecolor(_ANN_connect_color)"
+ ;
+ endfor
+ endfor
+
+ fi
+ endfor
+ % weights
+ if(_ANN_weights_b):
+ for j:=1 upto _ANN_i_couple-2:
+ newBox.scantokens(prefixANN)_weights[j](textext("$"&_ANN_weights&"_{ij}^{("&decimal(j)&")}$"));
+ scantokens(prefixANN)_weights.[j].c=1/4*(scantokens(_ANN_lb[j])[1].c+scantokens(_ANN_lb[j])[_ANN_n[j]].c+scantokens(_ANN_lb[j+1])[1].c+scantokens(_ANN_lb[j+1])[_ANN_n[j+1]].c);
+ drawObj(scantokens(prefixANN)_weights[j]);
+ endfor;
+ fi
+ % labels
+ if(_ANN_Legends_b):
+ newBox.scantokens(prefixANN)_legend_input(textext(_ANN_input_legend)) "framed(false)";
+ scantokens(prefixANN)_legend_input.n=scantokens(prefixANN)_input.s;
+ drawObj(scantokens(prefixANN)_legend_input);
+ newBox.scantokens(prefixANN)_legend_output(textext(_ANN_output_legend)) "framed(false)";
+ scantokens(prefixANN)_legend_output.n=scantokens(prefixANN)_output.s;
+ drawObj(scantokens(prefixANN)_legend_output);
+
+ if(_ANN_i_couple-1>3):
+ newBox.scantokens(prefixANN)_legend_hidden(textext(_ANN_hidden_legend)) "framed(false)";
+ scantokens(prefixANN)_legend_hidden.n=scantokens(prefixANN)_hidden.s;
+ drawObj(scantokens(prefixANN)_legend_hidden);
+ fi
+ fi
+ % build global group
+ newGroup.scantokens(prefixANN)_global(for i:=1 upto (_ANN_i_couple-1): for j:=1 upto _ANN_n[i]:
+ scantokens(_ANN_lb[i])[j] if((i<_ANN_i_couple-1)or(j<_ANN_n[i])): , fi
+ endfor endfor);
+enddef;
+
+
+_ANN_label_nbr:=0;
+vardef labelANN(expr s)(expr a,b) text options=
+ % s: string for the label
+ % (a,b): point at which put the label in relative coordinate, that is
+ % $(0,0)$ at bottom left of the bounding box of the complete graph and
+ % $(1,1)$ at top right.
+
+ save _xmin, _xmax, _ymin,_ymax;
+ save prefixANN;
+ string prefixANN;
+ _ANN_label_nbr:=_ANN_label_nbr+1;
+
+ prefixANN:="ANN"&decimal(_ANN_instance_nbr);
+ (_xmin,_ymin)=scantokens(prefixANN)_global.sw;
+ (_xmax,_ymax)=scantokens(prefixANN)_global.ne;
+ newBox.scantokens(prefixANN)_label scantokens(decimal(_ANN_label_nbr))(textext(s)) options;
+ scantokens(prefixANN)_label
+ scantokens(decimal(_ANN_label_nbr)).c=(_xmin+a*(_xmax-_xmin),_ymin+b*(_ymax-_ymin));
+ drawObj(scantokens(prefixANN)_label scantokens(decimal(_ANN_label_nbr)));
+enddef;
+
+endinput
\ No newline at end of file
Property changes on: trunk/Master/texmf-dist/metapost/mp-neuralnetwork/mp-neuralnetwork.mp
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/tlpkg/bin/tlpkg-ctan-check
===================================================================
--- trunk/Master/tlpkg/bin/tlpkg-ctan-check 2025-01-28 21:08:01 UTC (rev 73626)
+++ trunk/Master/tlpkg/bin/tlpkg-ctan-check 2025-01-28 21:09:25 UTC (rev 73627)
@@ -597,7 +597,8 @@
moloch mongolian-babel montserrat
monofill montex moodle
moreenum morefloats morehype moremath moresize
- moreverb morewrites morisawa movement-arrows movie15 mp-geom2d mp3d
+ moreverb morewrites morisawa movement-arrows movie15
+ mp-geom2d mp-neuralnetwork mp3d
mparhack mparrows mpattern mpchess mpcolornames
mpfonts mpgraphics mpkiviat
mpman-ru mpostinl mptopdf mptrees msc msg mslapa msu-thesis mtgreek
Modified: trunk/Master/tlpkg/libexec/ctan2tds
===================================================================
--- trunk/Master/tlpkg/libexec/ctan2tds 2025-01-28 21:08:01 UTC (rev 73626)
+++ trunk/Master/tlpkg/libexec/ctan2tds 2025-01-28 21:09:25 UTC (rev 73627)
@@ -1843,6 +1843,7 @@
'moderncv' => '&POST_deref_symlink',
'montex' => '&POSTmontex',
'mp-geom2d' => '&POST_onelevel',
+ 'mp-neuralnetwork' => '&POST_onelevel',
'mpfonts' => '&POSTmpfonts',
'mpkiviat' => '&POST_onelevel',
'mptopdf' => '&POSTmptopdf',
Modified: trunk/Master/tlpkg/tlpsrc/collection-metapost.tlpsrc
===================================================================
--- trunk/Master/tlpkg/tlpsrc/collection-metapost.tlpsrc 2025-01-28 21:08:01 UTC (rev 73626)
+++ trunk/Master/tlpkg/tlpsrc/collection-metapost.tlpsrc 2025-01-28 21:09:25 UTC (rev 73627)
@@ -35,6 +35,7 @@
depend mfpic4ode
depend minim-hatching
depend mp-geom2d
+depend mp-neuralnetwork
depend mp3d
depend mparrows
depend mpattern
Added: trunk/Master/tlpkg/tlpsrc/mp-neuralnetwork.tlpsrc
===================================================================
More information about the tex-live-commits
mailing list.