# Perceptron

> Inputs, weights, a sum, and an activation: one artificial neuron. A Neural networks example with its complete LaTeX source, ready to copy or open in TeXeR.

A Neural networks example in the TeXeR TikZ library: https://texer.org/library/neural-networks/perceptron

Package: [Neural networks](https://texer.org/library/neural-networks.md), on CTAN at https://ctan.org/pkg/pgf.

Tags: perceptron, neuron, activation

## Source

```latex
\usetikzlibrary{arrows.meta, positioning}

\begin{tikzpicture}[
  node distance=6mm and 14mm,
  every edge/.style={draw, -{Stealth}},
]
  \node[circle, draw, minimum size=10mm] (sum) {$\Sigma$};
  \node[left=of sum] (x2) {$x_2$};
  \node[above=of x2] (x1) {$x_1$};
  \node[below=of x2] (x3) {$x_3$};
  \node[draw, right=of sum, minimum size=10mm] (act) {$\sigma$};
  \node[right=10mm of act] (y) {$y$};

  \path (x1) edge node[above] {$w_1$} (sum)
  (x2) edge node[above] {$w_2$} (sum)
  (x3) edge node[below] {$w_3$} (sum)
  (sum) edge (act)
  (act) edge (y);
\end{tikzpicture}
```

## As a complete document

The same example in a document that compiles on its own with pdfLaTeX:

```latex
\documentclass[margin=3mm]{standalone}
\usepackage{tikz}
\usepackage{xcolor}
\usepackage{amsmath}
\usepackage{amssymb}
\usetikzlibrary{arrows.meta, positioning}

\begin{document}

\begin{tikzpicture}[
  node distance=6mm and 14mm,
  every edge/.style={draw, -{Stealth}},
]
  \node[circle, draw, minimum size=10mm] (sum) {$\Sigma$};
  \node[left=of sum] (x2) {$x_2$};
  \node[above=of x2] (x1) {$x_1$};
  \node[below=of x2] (x3) {$x_3$};
  \node[draw, right=of sum, minimum size=10mm] (act) {$\sigma$};
  \node[right=10mm of act] (y) {$y$};

  \path (x1) edge node[above] {$w_1$} (sum)
  (x2) edge node[above] {$w_2$} (sum)
  (x3) edge node[below] {$w_3$} (sum)
  (sum) edge (act)
  (act) edge (y);
\end{tikzpicture}
\end{document}
```
