In this video, we'll make use of hands on Podemos in Numpty Tenzer flow and pipework to illustrate
basic Tenzer arithmetic, including the Matamata product.
Already of the basic Tenzer arithmetic operations, some of the most basic are simply adding or multiplying
our Tenzer by a scalar value.
It simply applies that scalar to all of the elements in the Tenzer and the shape of the Tenzer is retained.
As an example, let's take our number Pi Matrix, Tensor X, which has this shape and these values,
we can multiply that entire Tenzer by two and all of the elements are multiplied by two.
We can add the number two and then that would add two to all of the elements in the Tenzer, or we can
even apply multiple and then just the standard order of operations applies.
So if we do multiplication and addition on intenser with scalar values, then we'll do the multiplication
first and then the addition.
So, for example.
Twenty five.
Times two plus two is fifty two, and you can confirm that the math works out for each one of the individual
elements, the shape of the Tenzer is exactly the same.
Three rows, two columns that went in.
In my torch, we can perform these scalar multiplications and additions in exactly the same way as we
do in Numpty.
So we simply apply them at the end in exactly the same way.
So the python operators are overloaded, so when you use multiplication or addition with these simple
asterisk and plus sign symbols, the standard symbols that we're used to for doing arithmetic in Python,
when we do those on a PI towards Tenzer, the python operators are overloaded.
So we are actually performing the torch dot mull method or Tausig add method for multiplication and
addition respectively.
But it just happens all behind the scenes and you don't even have to worry about it.
So here we're actually formally using the methods, we get the exact same results and we're using the
same exact methods in the back end, same kind of idea for tensor flow.
You can you can use the standard times two plus two because likewise the python operators are overloaded
when you use a tensor flow matrix.
So this is equivalent to to multiply and add.
So get the same results using the exact same methods.
Either way that you do these scalar operations.
Cool.
So that covers multiplying, in addition and so on by scalar, of course, the same kinds of things
hold true for subtraction and division and so on.
Now, a little bit more interesting than the scale of operations is something called the Habimana product
or the Element Y's product.
And so if two Tensas have the same size, we can often apply operations element wise, and that is how
we would do it by default.
Typically in these libraries.
So this is not matrix multiplication.
You need to be careful about that.
We will cover matrix multiplication shortly.
But instead, this is just the element Y's product or the Hatami product.
And so the mathematical notation is this dot with a circle around it to signify this Hazama product.
In this case, we're applying it on two matrices, Matrix X and Matrix A.
So here's what Matrix X looks like again.
And so we can create a Matrix A. by adding two to every element of a we did this just above here.
Now that we have our matrix, we can add it to our Matrix X because they have the same size, and when
we do that, everything, all the additional have been on an element wise basis of twenty five plus
twenty seven is equal to fifty to two, plus four is equal to six and so on, all the way through this
three by two matrix.
And when we use the.
Asterisk, the typical multiplication operator we are performing this, had a MAAD product, so we're
doing this operation right here on a an X and so it's 11 Y, so we have twenty five times.
Twenty seven is equal to six hundred and seventy five and two times four is equal to eight.
That's an easier one to do in your head to confirm and so on all the way through all of the elements.
So that's no high and with high torch intenser flow, it's all the same.
So we can create our up a matrix and torch in the same way as we did in Numpty and then perform the
same kind of element was Edition and Hatam, our product operations on it.
Same thing in Tenzer flow.
All right, so those are some of the most basic arithmetic operations.
Up next, we've got reduction, another common Tenzer operation.