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

With 3-dimensional arrays, like in ​lolol​ below, we’ll have a 3rd level of brackets:

17

lolol ​= ​[[[​1​,​5​,​6​,​2​],

[​3​,​2​,​1​,​3​]],

[[​5​,​2​,​1​,​2​],

[​6​,​4​,​8​,​4​]],

[[​2​,​8​,​5​,​3​],

[​1​,​1​,​9​,​4​]]]

The first level of this array contains 3 matrices:

And

[[​1​,​5​,​6​,​2​],

[​3​,​2​,​1​,​3​]]

[[​5​,​2​,​1​,​2​],

[​6​,​4​,​8​,​4​]]

[[​2​,​8​,​5​,​3​],

[​1​,​1​,​9​,​4​]]

That’s what’s inside the most outer brackets and the size of this dimension is then 3. If we look at

the first matrix, we can see that it contains 2 lists ​—​ ​[​1​,​5​,​6​,​2​]​ and ​[​3​,​2​,​1​,​3​]​ so the size of

this dimension is 2 ​—​ while each list of this inner matrix includes 4 elements. These 4 elements

make up the 3rd and last dimension of this matrix since there are no more inner brackets.

Therefore, the shape of this array is ​(3, 2, 4)​ and it’s a 3-dimensional array, since the shape

contains 3 dimensions.

Fig 2.05:​ Example of a 3-dimensional array.

Anim 2.05:​ ​https://nnfs.io/jps

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

Saved successfully!

Ooh no, something went wrong!