Ha ha right.
So in this lesson we're finally gonna start talking about tenses the tenser and tenser flow.
Now what is the tensor.
I find that googling for the definition or for other people's explanation often comes back with quite
difficult to understand definitions and results.
And the reason is that yeah tenses are somewhat complicated and abstract but they're also used in many
different fields outside of neural networks and machine learning and the thing is you tend to get very
different explanations depending on who you're asking.
Everybody is gonna give you their point of view.
So a mathematician is going to have a very different starting point for explaining what a tensor is
than say a software engineer and a physicist will also give you a very very different examples for the
uses of tenses than say a civil engineer from our perspective we're going to be working with data and
numbers right so that we can start to understand what a tensor is is that it's essentially a way of
storing data in some kind of structure.
If we only had a single number then things would be easy on the other hand if we had lots of numbers
then we have to make a choice as to how to represent those numbers one way that we've seen already is
a list or a single column of numbers.
We sometimes referred to that as a vector a computer scientists on the other hand would look at the
same thing and call it an array and this array only has one dimension.
Sometimes on the other hand we had more numbers and we were working with data frames or matrices.
In this case our data was structured like in an Excel spreadsheet.
So we had two dimensions.
Rows and columns and then things got real fancy.
When we added that third dimension.
Remember how with color images we had the red green and blue channel.
In that case we started stacking these spreadsheets on top of one another.
And that's because we had three dimensions.
When we're talking about tenses and we're talking about these dimensions the number of dimensions actually
has a name.
It's called the rank.
So a single number or a scalar has a rank of 0 a vector or a column of numbers would have a rank of
1.
The Matrix would have a rank of 2 and our stacked matrix would have a rank of 3.
Now when working with tensor flow we're actually working with a data structure that can have any number
of dimensions.
So a tensor is basically a container with and dimensions.
So now we have a proper name for that stacked spreadsheet of our GDP values.
We are essentially working with a three dimensional tensor so the way to think about a tensor from our
perspective is a generalization of our friendly neighborhood matrix to end dimensions from two dimensions
to end dimensions and because we already have words for one dimensional and two dimensional tenses like
vector and Matrix.
You're typically only see the word tensor used when people talk about anything with three dimensions
or more but the thing is there's actually more to tenses than just the way of holding data tensor is
also follow certain mathematical rules meaning you can multiply and add tenses together and generally
do linear algebra.
Similar to how we were multiplying matrices together and this kind of linear algebra is gonna come in
really handy when we are calculating the input and the output values of our neurons.
An example of the kind of calculation we will do is multiplying the output values of one layer of neurons
times the connection weights to figure out what the input values should be for the next layer.
So let's walk through this.
Suppose we've got these two layers right here and that blue layer that first layer is going to have
a certain number of outputs.
So that first neuron might have an output of two point two.
The second one seven point one.
And so on.
Now I'm going to substitute some symbols instead of these numbers.
I'm just gonna call these outputs output one output to up with three up until output 5 and similarly
I'm going to give the inputs in that second layer and name two.
I'm going to call these ones input 1 into in 3 and 4 so here's the question how would we calculate the
values of these inputs for the green layer remember these inputs are the same ones that are going to
go into the activation functions of that green neuron to determine their output in turn.
But that's the next step.
So let's walk through this.
If we only had to worry about the connection weights we're gonna ignore biases for now.
Then we would use some linear algebra we would take all of those weights and then we would multiply
them by the outputs from that first layer.
And that's what we would get the inputs to the second layer.
The key here is to multiply the output of the first layer.
Times the weights if you look at these weights here you can see I've put low subscript next to them.
So the interesting thing is here that that first row weight 1 1 weight one to weight 1 3 basically correspond
to the connection weights of this neuron and there's five of them.
Right.
One two three four five.
Because this neuron is receiving an input from these five blue neurons.
So weight 1 1 will be multiplied with output one.
Weight 1 2 will be multiplied without put 2 and all of these then will be added up and then we get that
sum which is gonna be the weighted input for this neuron and the same thing will happen to that second
row that second row of weights will correspond to all of these weights right here for neuron number
two road number three will correspond to these weights here for neuron number three and this one for
near a number for the columns on the other hand correspond to these weights right here all connected
to that first blue and you're on the second column will be these for the third column will be these
for weights in essence this is the calculation that takes place when we talk about the neurons taking
a weighted average of their inputs let's keep this calculation in mind as we head back to our Jupiter
notebook and set up our tensor is and our layers.