10.02.2021 Views

Neural Networks from Scratch in Python by Harrison Kinsley, Daniel Kukie a

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 2 - Coding Our First Neurons - Neural Networks from Scratch in Python

27

Anim 2.13:​ ​https://nnfs.io/lqw

Recall that in Python, and in our case, lists are useful containers for holding a sample as well

as multiple samples that make up a batch of observations. Such an example of a batch of

observations, each with its own sample, looks like:

inputs ​= ​[[​1​, ​2​, ​3​, ​2.5​], [​2​, ​5​, ​-​1​, ​2​], [​-​1.5​, ​2.7​, ​3.3​, ​-​0.8​]]

This list of lists could be made into an array since it is homologous. Note that each “list” in this

larger list is a sample representing a feature set. ​[​1​, ​2​, ​3​, ​2.5​]​, ​[​2​, ​5​, ​-​1​, ​2​]​, and

[​-​1.5​, ​2.7​, ​3.3​, ​-​0.8​]​ are all ​samples​, and are also referred to as ​feature set instances ​or

observations​.

We have a matrix of inputs and a matrix of weights now, and we need to perform the dot product

on them somehow, but how and what will the result be? Similarly, as we performed a dot product

on a matrix and a vector, we treated the matrix as a list of vectors, resulting in a list of dot

products. In this example, we need to manage both matrices as lists of vectors and perform dot

products on all of them in all combinations, resulting in a list of lists of outputs, or a matrix; this

operation is called the ​matrix product​.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!