lecture 5
ML applications,
+
introduction to
vector and matrix,
addition and multiplication,
+
neural networks part 1:
what are they doing in action?
that looks like a lot..?
lecture plan:no construction today, we'll have fun ML applications to look at
scope for these three lectures (next week double lectures)
high-level ML problem solving mindset:
- what are the problems that can be potentially solved by ML models?
- if so, how to use ML models to solve that?
on low-level technical detail
- grasp as much as possible, it helps
- let it go (fall back to high-level understanding) when necessary, it also helps
this combination is in line with this unit's assessment
lecture plan
first half:
- fun ML applications ☝️
- vector and matrix, addition and multiplication
second half:
- fun ML applications ✌️
- neural networks part 1: what are they doing in action
SeAts APp SEAtS ApP SEaTS APP
GAME TIME!
the 12
😈 ML (SL) in action part 01 (art works)πŸ‘€
question: we have models that can detect human poses, human figures or faces, what can we do with these detection results?
Performance and Pose Estimation
Discrete Figures a cool performance with something potentially similar to this ML model in apple
we'll look into pose estimation later, it is similar to the face landmarks detection
Installation and Object Detection (human figure detection)
"Hello" an installation with something potentially similar to this ML model in apple
Installation and Face Recognition
Female figure by Jordan Wolfson a "strong" installation that uses good old face recognition models
they all embed the idea of "tracking" and ML models only serve as a tool.
Ideas matter. Don't get trapped in technical details. You have most of the high-level understanding ready, can start thinking now :)
Now that we know we have models that can detect human poses, human figures, faces, what can we do with these detection results?
Recap{
understand vs. hard memorising
- generalisability
- simple is beautiful: explanation in simple words
scary notation, perceptual adaptation and repeated exposure
repeated exposure index: 小 index
data types, numeric and categorical
model: input, process and output
function as a mathematical embodiment of "input, process and output"
model can be seen as a set of function. (big) function can be a combination of (small)functions.
function types, aka the scaffold;
one function type corresponds to a characteristic shape
linear, relu and sigmoid
function parameters (weights and biases), aka the muscle
supervised learning, a subcategory of ML
characteristic: learning with "correct answers" (labels)
two types of SL tasks
- classification: tasks where the output are categorical values
- regression: tasks where the output are numeric values
questions!!!
who's singer of this song?
what's bitcoin price tomorrow?
high-level introduction of a SL model (in particular neural networks, see next half) training process
1. have an initially guessed model with scaffold and muscle (often random and imperfect)
->
2. feeding data into the (imperfect) model
->
3. get the (imperfect) model output
->
4. measure how wrong this output is compared to the correct answer
->
5. using the measurement to update the model's muscle
->
back to step 2 and repeat until some satisfaction criteria
what do we train the model for?
to capture the numeric relations between input and labellel outputs in the dataset,
so that we can use the model to make educated prediction given any inputs especially the unseen ones (reality in flux and noises)
/*end of recap*/
}
cute math warm up
no python or numpy syntax to remember (can always look up), just the maths ideas!
scalar, vector, matrix: different ways to organise numbers (whiteboard)
why? we have to use numbers to represent stuff and one single number is often not enough. There are usually many numbers hence it is inevitable to look at how these numbers are organised.
one single number, scalar
example of data being a scalar? 🌀
an array of single numbers, vector: number of elements = number of dimensions
example of data being a scalar? πŸ”‰
IMPORTANT: one-hot encoding of categorical data
apart from seeing vector as a sequence or a dot, another aspect of seeing vector as a pointer with direction (to be used later)
an array of vectors, matrix
describing a matrix by its shape(dimensionality) : m rows x n columns
example of data being a matrix? 🩻
vector can be seen as a special case of matrix: K rows x 1 columns (or 1 rows x K columns)
convert from matrix to a vector: "flattening" (on whiteboard)
though the amount of numbers stays the same, something is lost after flattening:
imagine you are a numebr sitting inside a matrix and look around
imagine you are a numebr sitting inside a vector and look around
the neighboring relation/information is lost (they used to be neighbors but now they are not)
impact of this to be demonstrated later
addition: easy, just add
example of scalar, vector and matrix addition
high-level 01: accumulation, combination, in graphical thinking: translation(shifting)
high-level 02: parts to be added together must have the same dimensionality and there is no changes in dimensionality after addition (why we care about this?)
catching programmers breaking the maths rules for the sake of convenience: to try in colab: what happen when adding a scalar to vector ?
(it has an implicit step of expanding the scalar to match the dimension of vector via duplicating)
multiplication: easy, just multiply
example of a scalar, vector or matrix multiplied by scalar
multiply two scalars? πŸ€ͺ
multiply two vectors?
1. element-wise product
2. dot product
multiply a vector with a matrix? IMPORTANT
refer to this video to see how the shapes (or sizes) of matrices effect the multiplication result as well as how to multiply
high-level 01: scaling and weighting
high-level 02: dot product as a similarity measurement between two vectors
high-level 02 (take this as a fun fact) : what are the most dissimilar vectors possible to a given vector?
high-level 02 (take this as a fun fact): when their dot pruduct is 0, orthogonal (no shadow after projection)
high-level 03 when a vector is multiplied with a matrix: linear transformation including scaling and shearing
high-level 04 when a vector is multiplied with a matrix: it can change the dimension of the vector! (finally summon the demon...)
😈 ML (SL) in action part 02 (applications)πŸ‘€
Shazam identify songs
BirdNET identify bird species given bird sound/songs
have a guess on what the data is like to train the BirdNET
this question is basically equivalent to "what are the input and outputof BirdNET?"
first step to prepare dataset for a SL task: formalise the problem, identify the input and output (we'll talk through this process in the future)
any volunteers? πŸ₯°
start thinking about the presentation, aka dreaming regardless of feasibility
here's my take on "what are the problems that can be potentially solved by machine learning?"
- mundane, repetitive works that i don't bother doing (transcribe handwriting into texts on computer, etc.)
- "it'd be great to have that" but i don't know how to implement that just using programming (face recogtion, etc.)
- just for fun πŸ₯Ή
neural networks part 1
time to demystify neural networks in action (during using/inference/deployment, not training)
we will be looking at fun analogies and origins of neural networks next week
following content only serves as a perspective from a continuation on our main theme - "vector and matrix" introduction
in other words, let's look at the computations only (crack the hardest part πŸ€“), leave the interpretations to next week (it can only get easier πŸ˜‰)
the computation: what and how (hard memorising for now)
the interpretation: why
when we are using/calling the model and feeding it with an input, what is happening inside the model(the "process")?
long story short, for simple neural networks, or "multilayer perceptron" as you may see somewhere:
its input is a vector (if it is a matrix like image then flatten it)
this vector is then feeded into the first layer computation, and then second layer computation, and then next layer ...
each layer can be seen as a function that takes a vector as intput, and outputs a new vector
each layer function has a scaffold and its own muscle (weights and biases).
in multilayer perceptron, different layers have almost exactly the same scaffold.
because they are almost identical, let's zoom in to one layer function:
the computations that is happening inside each layer function is (simply):
1. multiply the input vector(representation or feature vector) with a matrix(weights), output a new feature vector
2. add a vector(bias) to the feature vector(from last step's output), output a new feature vector
3. apply some activation functions to the feature vector (from last step's output), output a new feature vector
combine 1,2,3 together we have:
SomeActivationFunction(v_feature * weights + bias)
this looks just like a linear function, wrapped inside an activation function
we'll see what "being wrapped inside an activation function" means next week
!weights are in the form of matrix
- multiplying input vector with weights matrix is where dimensionality change could happen
!biases are in the form of vector
- adding a vector to another vector can not change dimensionality
no hard memorising
recall chaining two functions: using previous output from function 1 as the new input to function 2
combine 1,2,3 together we have:
SomeActivationFunction(v_feature * weights + bias)
chaining is happening already
if one layer corresonds to one function of this

SomeActivationFunction(v_feature * weights + bias)
where v_feature is the input, note weight and bias are NOT input

to add more layers is to apply another round of layer function using last layer's output feature vector as input, aka chain more functions exactly like that together
demonstrate the layer function chaining on whiteboard...
till it reaches the last, output vector (recall all those output examples we have discussed, including dog-or-cat classification)
how many layers are there? it is predefined (as part of the function scaffold remember?)
小index: 2 months
congrats! that is a rather in-depth walk through in multilayer perceptron with MSc level of maths details and you just learned it from scratch!
summary of today 😎
scalar, vector, matrix πŸŽ›
- what they are: diff ways to group numbers
- vector use case: one-hot encoding categorical data
- shape of matrix: #rows x #cols
- rules for addition
- - shapes must be exactly the same
- multiplication between vectors: dot products or element-wise products
- - dot products: shape and order matters, always row vector times col vector, a single number as output
- multiplication between matrix:
- - the rule of shapes: M x N N x K = M x K
- - what to multiply: dot products in order
simple neural networks part 1 🧠
- each layer is a big function, takes a feature vector as input and split out new feature vector
- inside this layer function, it is matrix multiplication, vector addition and wrapping around with activation function(more on this later)
final words
it is all about matrix multiplication. 2D/3D rendering is also about matrix multiplication. So does coin mining.
who is good at matrix multiplication?
introducing, the real godfather/godmother of computational modernity: πŸ₯
https://consent.yahoo.com/v2/collectConsent?sessionId=3_cc-session_e0dce1a9-ce8d-499b-9bdf-a5beb5b5c8f3
ML applications found by lovely students:
Move Mirror by Google Creative Lab (pose estimation)
AI Voice Generator and Cloner (text to speech)
Beyond Imitation (pose prediction: given a sequence of poses as input, predict the next pose)
chimera-painter (conditional GAN: generative model)