Type to search…

Fonaments

Foundational mental models that are essential for understanding how neural networks work.

Introducció

We’ll work our way up from the simplest possible building blocks to show that we can build complicated functions made up of a “chain” of constituent functions and, even when one of these functions is a matrix multiplication that takes in multiple inputs, compute the derivative of the functions’ outputs with respect to their inputs.

shell
uv init math
cd math
uv add numpy

Functions

As with neural nets, there are several ways to describe functions, none of which individually paints a complete picture.

<Plot data={[ { x: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], y: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], mode: “lines”, }, ]} layout={{title: “Chart”}}/>

Math

Here are two examples of functions

f1(x)=x2f2(x)=max(x,0)

This notation says that the functions, which we arbitrarily call f1 and f2, take in a number x as input and transform it into either x2 (in the first case) or max(x, 0) (in the second case).

Code

També pots escriure aquestes funcions en Python:

python
math.py
def f1(x):
    return x ** 2

def f2(x):
    return max(x, 0)

assert f1(2) == 4
assert f2(2) == 2

You're reading a preview.

Sign in to read the full article. Any account opens 10 free articles a month; students and teachers read their course pages without limit.

Sign in