# Notes on The Little Learner: Parameters, Tensors, and Mathematical Operations

DevFeed: [Notes on The Little Learner: Parameters, Tensors, and Mathematical Operations](<https://devfeed.tech/articles/little-learnings-28092.md>)

Original publisher: [Read original article](<https://jlongster.com/little-learnings>)

Author: James Long

Published: 2024-09-02T12:00:00Z

Content type: tutorial

Language: en

Sources: [James Long](<https://devfeed.tech/sources/james-long.md>)

Topics: [dataset](<https://devfeed.tech/topics/dataset.md>), [math](<https://devfeed.tech/topics/math.md>), [implementation](<https://devfeed.tech/topics/implementation.md>), [render](<https://devfeed.tech/topics/render.md>)

Tags: [dataset](<https://devfeed.tech/tags/dataset.md>), [graph](<https://devfeed.tech/tags/graph.md>), [implementation](<https://devfeed.tech/tags/implementation.md>), [learnings](<https://devfeed.tech/tags/learnings.md>), [math](<https://devfeed.tech/tags/math.md>), [render](<https://devfeed.tech/tags/render.md>)

## AI overview

Notes working through The Little Learner explain function parameters, datasets, scalars, tensors and tensor rank, then implement extended mathematical operators such as addition and sum.

## Source excerpt

(note: skipping interactive content block) ^f3bf01 ^aeae51 A collection of notes as I work through The Little Learner. (note: skipping interactive content block) ^0c0c15 Chapter 1 1.5: graph a line with $w$ and $b$ parameters const f = (w, b) => x => w * x + b; render(graph(f(100, 10))); render(graph(f(10, 0))); ^2b4784 1.14: reverse the order to make $x$ an argument and $w$ and $p$ parameters // A version where w and b become parameters _after_ `x` const f = x => (w, b) => w * x + b; return graph(x => f(x)(2, 20)); ^14f8ec x is the argument of the line, while w and b which come after are parameters 1.19 plot the xs, ys dataset const xs = [2, 1, 4, 3]; const ys = [1.8, 1.2, 4.2, 3.3]; return graph({ marks: Plot.dot(zip(xs, ys), { x: n => n[0], y: n => n[1], fill: "black" }), domainX: [0, 5], domainY: [0, 5] }); ^dc0f98 Rule of parameters: every parameter is a number Given x and y, or arguments to a function, we can walk backwards and figure out the parameters and then use that to predict other y values for a given x θ is the parameter set (lowercase theta) Given θ, there parameters if it referred to as θ$_1$, θ$_2$, etc const f = θ => (θ_1, θ_2) => θ_1 * x + θ_2 ^7052b4 Chapter 2 "Scalars" are real numbers A "tensor" is a vector of scalars: [2.0, 1.0, 4.3, 4.2] The book uses tensor$^1$ with a superscript Tensors can be nested, and the superscript indicates the level of "nested" "elements" are the individual values in the tensor I think tensor$^1$ (with the 1 superscript) specifically means a vector of scalars, and higher tensors have tensors as elements All tensors$^m$ must have the same number of elements A scalar is atensor$^0$ 9 is tensor$^0$ [9, 9, 9] is tensor$^1$ [[9, 9, 9] [9, 9, 9]] is tensor$^2$ 2.25: define a function that finds the rank of a tensor window.scalarp = v => typeof v === "number"; window.rank = t => (scalarp(t) ? 0 : 1 + rank(t[0])); return log(output => { output(rank(4), 0); output(rank([4, 1]), 1); output(rank([[4, 1], [3, 6]]), 2); output(r