Now we have some basic knowledge on tensors.
Let's go ahead and create them with TensorFlow.
So first things first, we'll import TensorFlow as TF and then you should note that because we're using
CoLab, we do not need to install TensorFlow before making use of it.
All we need to do here is just import and we're good to go now.
First thing we're going to do is we're going to have our tensor, which we'll call tensor zero D And
the way we are going to create this tensor is by calling on the constant method.
So we have tensorflow's constant method.
And then we specify, for example, that we want this to be, let's say four.
So that's it.
That's how we create a zero dimensional tensor.
You could see here from the documentation that this constant method takes in a value, takes in a data
type, takes in a shape and a name.
But for now, we pass in only this value right here.
And then we could go ahead and print this.
So let's have tensor, um, zero d run that you could see right here.
We've had this tensor which has a value four it has no shape and it's of type int 32 With this we could
go ahead and build out our tensor one D tensor one D.
We have as usual, our constant method.
But this time around, because it's one D, we're going to have a list.
We're going to take this list we had here to zero negative three and then put in this.
Now right here we have to zero and negative three.
Now let's print this out.
We have tensor one D and there we go.
You see, we have the value, which is this one D or this list.
We could say shape right here.
And then the data type.
Now let's modify this and say we have eight and let's say 90.
Let's run this now and check out its shape.
You see here, this is our new list or this our new tensor.
And then you see now it's five because we have five elements in here.
But again, this is still an integer.
So let's add this here.
Change this to a float and then see what we have here.
Now, this is a float, so it's still, um, inputs, but this time around floats same shape, but the
data type changes from int to float.
Let's get back to integer and then we move now to the 2D tensor.
So we've looked at 0D1D to create a 2D tensor.
It's going to be quite as simple as we have done with the zero D and one D.
So here we have two D and then we have a zero constant.
And then, um, let's open up this square brackets.
So we have the square brackets right here, open up and then we have.
This 2D tensor we have seen already.
So let's have this right.
Here we have 120.
We put a comma to move to the next row or to the next line.
We have three, five minus one.
Then we have one, five, six, and then we have two, three, eight.
Okay.
So as you could see here, we have this 1D tensors which we stack and which will form our 2D tensor.
Now, as usual, we have our constant method which takes in this value.
And it should also take note of the fact that we have this outside of this stacked 1D tensors.
Now we have this.
Let's go ahead and print out tensor 2D.
We have tensor 2D and there we go.
As you could see, we have our 2D tensor.
That's it.
We have the shape four by three, which is what we expected.
And then the data type is Int32.
From here we move on to the 3D tensor, which is essentially made of this 2D tensors which have been
stacked together.
So let's go ahead and see how to create this with tensor flow.
We'll start by putting together those 2D tensors.
We had 12035 minus one.
So that's it, three, five minus one.
And then we have all those remaining 2D tensors.
So let's get here.
We have tensor three, tensor three D is a constant.
We have our square bracket here and then we simply copy this, copy this, and then paste this in here.
Now let's print this out and see what we get.
So here we have tensor two.
The.
As you could see, we get an error.
And this comes from the fact that we omitted commas.
Now, if you look at this, you'll see that between one, one, D and another one D to form this two
d.
There is a comma.
And so this means that between this two D and this other two D, there should be a comma.
So let's have this comma here.
Let's have this comma.
Let's have this comma and this comma.
Okay, so let's run that again and see what we get.
As you could see, we have this our 3D output of shape, four by two by three.
And that's exactly what we expect to get data type int 32.
Now, before we move on, we could we should note that we could also do let's, let's have this here.
We could also do, um, tensor 3D shape to obtain this tensor shape.
So you see that we have that right there.
We could replace this zero.
We could have one C that's zero.
That's one.
That's two.
Um, there we go.
Let's.
Let's have one.
That's one.
Um, that's it.
Okay.
And also, we could also have.
Yeah, let's say three.
We could do nzime.
And this gives us a value of three showing us that our tensor is a 3D tensor at this point.
We've looked at zero D, one, D, two, D, and even the three d tensor.
Let's go ahead and check out a 4D tensor.
But to construct a 4D tensor, we need several 3D tensors.
So let's have this.
Here we have this 3D.
Well, we saw this already.
This is the 3D.
And then we move to this other one right here.
Others, two others.
We, we have this other 3D and this other 3D.
And then now if we stack this three 3D up, what we will obtain will be a 4D tensor.
See, we have this one, we add this other and we have this other.
So now we have here a four dimensional tensor which is made of three three dimensional tensors.
Now, you should know that this could be two, this could be four, this could be whatever number.
So if we consider only this two, then we're talking about two, three dimensional tensors.
But what's so important to note here is the fact that once you stack several 3D tensors, you create
a 4D tensor.
Now, at this point, you could take it as an exercise to create your own 4D tensor so you could pause
the video.
But um, we are going to go ahead and show you how to create this.
First things first.
We're going to take up our 3D here.
We have this 3D tensor.
Let's just copy this.
There we go.
We paste this out here.
Let's repeat that operation.
Copy and paste again.
But now let's modify some values.
So let's say we have 1326.
Let's just randomly modify this.
23 So it's now this these are the three different from the other one, say 30.
Okay, now let's copy this again and then paste out here.
So we have the three 3D tensors.
Um, let's say this is one.
Oh, let's just add zeros.
We have here, um, 23, um, to four and say two.
Okay, so now we have our three 3D tensors, we have this one, we have this other one and then we have
this other one.
Now to create our 4D tensor.
As usual, we call on our, our constant method.
So we have four D um, we have the constant and as usual, we have our square brackets which will open
up.
And then now we just simply take this copy all this to the end, cut this from here and then paste this
out here.
Okay, so we see we have three of this, um, 3D tensors.
Now, remember last time when you were separating two 3D tensors or between the 3D tensors?
We need to have a comma.
So here we're going to have this comma, and then here we're going to have this comma.
And here we have comma.
Okay, so that's it.
So let's run this or let's print this out and then see what we get.
So here we have print, um, tensor 4D, There we go.
You could see from here we have our 4D tensor.
You see it's shape three by four, by two by three.
And this is because our 4D tensor is made of one.
Let's take this off.
It's made of one, two, three 3D tensors.
So that's why we have three.
And then for each and every one of these, we have four.
That's one, two, three, four, 2D tensors.
So here we have four.
And for every 2D tensor we have one, two, that's two rows and one, two, three.
That's three columns.
And that's now exactly what we have here.
So we still have the same data type.
We have our values, which you could have here, and that's it.
If we get back here, we'll see that we have different data types which we could use.
So instead of just this default int, we could have TF float say 32 and you'll notice that the output
as we have seen already, should have these decimals since we now dealing with floats.
Now the float we have in here is of type float 32 or specifically the float 32, meaning that the precision
value here is 32.
Now if we reduce this, if we reduce this, you will see that you would actually have the same output.
But the difference is that less memory is allocated for storing this tensor as compared to maybe even,
let's say the 64 that's float 64.
And so in certain contexts where we have the memory constraint, we would want to use the lower precision
tensors in the documentation.
You could have all the different data types of which are supported in TensorFlow.
So here we have quantized data types and talking about quantization, we're going to treat this in subsequent
sections and so don't bother for now if you don't really master this.
Um, here we have the brain floating point here we have the boolean here, we have complex in its 128
and 64 bit versions.
Here we have the double, which in fact means the double precision floating point.
Now this is double because the float 32 is a single precision.
So here we have single the float 16 is half prediction or precision, and then the double is double
precision.
Here we have the ints and the different versions or the different precisions, or we have the quantized
ints.
We have resource, we have string, we have unsigned int.
And then we have variant.
Getting back to the code, if for example, here we had this float, let's just add this decimal.
So we suppose that this is a float and then now we do int let's say in 64 we run that you will see that
we will obtain an error.
So let's have this here.
What do we see?
We told that we cannot convert this tensor to or to eager tensor of data type in 64.
But now if we use the cast method, if we do TensorFlow cast and then here.
All right, let's take this back.
Let's let's have our TensorFlow or our tensor 1D and then let's take this off or let's yeah, let's
just have this float 64.
There we go.
Or let's say float 32, and then let's say we define some casted tensor or cast a tensor 1D and then
this casted tensor 1D is simply going to be the casted version of this or 1D tensor.
So here we have tensor 1D and then we specify the data type and then we say we want this to be in 16,
for example.
So here we're going to print out the tensor 1D and we're also going to print out the casted tensor 1D.
We getting this error we should have had TF DOT.
So let's have this here.
There we go.
And then let's look at what we have as output.
As you could see, thanks to the casting operation, we are able to get from this float to this integer
tensor.
And so this tells us that instead of coming right here and saying, for example, int 16 or let's say
in 32, it's preferable to make use of the cast method.
That said, let's say for example, instead of having this, that's instead of casting this into an
integer, we want to cast this into a Boolean.
So let's run this.
You see here that we get all of true except for this one here, which is false.
And that's simply because this is a zero.
So it looks like the water casting method does is for all the values which are different from zero,
they are true, but values equal zero, equal false.
We could also go ahead and create our own Boolean.
So let's say we have tensor tensor bool, let's call this tensor bool and then we have all this list
made of this tensor.
So we could have true, true false, true, true, false.
Okay, so let's print out tensor board and see what we get.
As you could see here, we have our output tensor of shape three and here is values.
You see the data type bool right here.
Now another data type, which you could look at is the string.
So let's, let's say we want to have tensor string.
Um, there we go.
Let's say we want to have um, hello world.
Hello world.
Let's print this out.
Tensor string.
There we go.
We have our tensor.
We could also put this in a list because right now this zero dimensional tensor.
So let's put this in a list and, uh, hello, world.
Hi.
And we'll close that.
And now we have this 1D tensor of Shape two, which is a string from here.
We would also look at how to create or how to convert a numpy array into a tensor.
So let's call this, um, NP array.
First of all, we'll start by importing numpy as NP.
We could just do that right here.
Import numpy as np.
There we go.
And then we have um np array and let's say we have NP array and then let's take in this here, let's
say one, two, 3 or 1 two, four.
There we go.
Print this out.
We have NP array right here.
Now we could make use of this TensorFlow convert to tensor method.
So let's say we have here converted converted tensor and we have um, convert to tensor which essentially
takes in a numpy array.
Now let's have this and then print out the converted um, tensor.
With that, getting back to the documentation, we could look at a couple of other methods, like the
AI method.
Here we have this AI method right here.
As usual, we have the well described method in the documentation.
Station, which comes with this short phrase explaining how it works.
It comes with this different arguments and also even some examples.
So getting back here, we told that this method permits us construct an identity matrix or a batch of
matrices.
So now we have this definition.
We could simply copy this out and then get back to the code right here, paste this out, and let's
say we call this, um, AI tensor.
AI tensor.
And for now we have this number of columns which is known the batch shape known data type float 32 name
known.
Now let's say we want to have three rows.
So we have number of rows which is equal three.
Now in this case, uh, we'll print this out.
So we see the kind of output we get here.
We have AI tensor here and there we go.
As you could see, we have this identity matrix where all the values of the matrix are zero except for
those of the leading diagonal.
Let's show clearly this leading diagonal right here.
Here we have our matrix, which is this.
And then we have this element of the leading diagonal, which is equal one.
Now, you should note that you could you could say, for example, um, let's say three times this and
you should have all the elements of the leading diagonal to be equal to three and the others zero.
So in this case, we now have something like this.
So you see all these three while the rest are zero.
Now let's get back.
Let's take this off Here we have our AI tensor and then we see that we could specify the number of columns
now here, uh, or previously where this was set to none.
We had a square matrix.
That is when you define the number of rows to be three.
The number of columns automatically takes up the value of three.
So we have a three by three matrix.
And obviously the type here is float32.
We could modify this and say, for example, 16 on that, let's try out bold after this.
There we go.
We have float 16.
Let's try out bold.
You see everywhere is false.
False.
False, false, false.
Except for the leading diagonal, which has true.
Now getting back, let's say here we have five and then now number of columns.
Let's say this to three.
You see right here, this is the output we get.
Now it's it acts like we have a five by five matrix.
So we suppose we add a five by five matrix where this will be zero zero.
This would have been zero zero.
This would have been one if this was five by five zero and then here zero one.
So this is what we would have had if we did not if we let this to to be known.
That is number of rows, equal number of columns.
But now that we've set number of columns to be three, this part has been cut off.
And so this is what we're left with.
Now, with that said, let's go ahead and take this back to Known and then let's set a batch shape.
So let's say this is three.
I'll run that.
As you could see, because we set this batch shape to be three.
Um, here we have this output which is three by five by five.
Well, let's, let's change this to two.
So you could see that this actually is responsible for deciding on what number of batches we have right
here.
So here we have two by five by five.
So essentially saying that you want to have this batch shape to be two like this means you want to five
by five matrices, which are identity matrices, that is, uh, which have their values all zeros except
for those of the leading diagonal which are equal one.
And so we see how we could create this 3D matrix or this 3D tensor from the AI method.
Now, we could go ahead and say for example, we want four year, let's run this and see what we get.
We should get two by four, two by four by five by five.
So here we have two by four, by five by five.
And that's it for the AI method.
We move on to the next method, the field method.
Here we have a method as defined here in the documentation which creates a tensor field with a scalar
value.
So here we have this field method which we're going to copy, but before testing out the code, you
could see here from this example that with this field method we have this tensor which takes which has
shape two by three and which has value nine on all different positions.
So let's get back here, paste this out.
Let's call this field tensor and let's say this dimensions.
Let's say we have three by four, and then let's say we want to have the value on, let's say five.
Okay, so let's print this out and see what we get.
Field tensor.
And there we go.
That's the output we get.
Now let's have this one, for example.
Run that.
So we were able to create this 3D tensor where all the values are, all the elements in each position
takes the value.
Five.
From here we go on to the Wands method and it should be noted that this one's method is quite similar
to the field method in the sense that this creates a tensor just like with the field method.
But the only difference is that here all the elements are set to one.
So you notice that here in this definition we do not have this value argument right here.
We had a value which we pass, but with the wands there is no value because the value by default is
one.
So let's have this here and then paste.
All right, here.
See, we have this ones, so we'll call this once tensor.
There we go.
We specify a shape, let's say five by three, and then we print that out.
So here we have once tensor.
And there we go.
We have this output matrix which is made of five rows one, two, three, four, five and three columns.
One, two, three.
Where all the elements of this tensor take up the value one.
Now, you could obviously do this to have or to obtain a 3D tensor.
So that's the output we get to see.
Five by three.
By two.
From here, we'll look at the ones like.
And what this one does is it creates a tensor of all ones that has the same shape as the input.
So what this means is if you have an input like this one, let's say we have um, 12, let's not make
that 112 one three and then 572 this actually a two by three matrix.
Let's change this.
So you see that this is two.
So we have the shape.
The shape is, um, two by three.
So its shape is two by three.
Now if this is the input here, if this is the input into our once like method, what will get us output
will be um, a matrix or tensor with this same shape that is with shape two by three.
So our output is going to be having a shape two by three, meaning that we're going to have um, two
rows and then one, two, three columns.
But the output or rather the values we're going to insert here will be all ones.
So now we're going to have 111111.
So hence the name ones like, so this like is actually for the shape of this.
So you imitating the input with respect to its shape.
Now getting back here you see we had this field tensor which is a one by three by four tensor.
So let's, um, let's have this right here.
Let's say we want to have, uh, one like Tensor.
There we go.
TF one like, and then we have field tensor field tensor.
There we go.
Okay, so let's print out this one's like tensor.
Now before printing, let's try to obtain the output.
So here we know that this is field tensor.
The shape is one by three by four.
So it means that we should have an output of shape one by three by four where all these values are ones.
So let's run that and make sure that that's the output we have.
There we go.
Says one by three by four.
And we have all ones.
From here we move to the Zeros method.
So it's quite similar to the ones here.
Just like with the ones we have all elements set to a given value with the ones, all the elements we
set to one with the zeros.
All elements are set to zero.
So that's essentially it.
Now let's just modify the code a little right here.
So this was once tensor.
Um, let's change the shape this three by two.
And then instead of once here, let's say zero here we have zeros and let's call this well, let's say
this is let's just copy this out and put out separately.
So here we have this, we paste that out here, we have zeros and here we have zeros.
Fine.
And here we have zeros.
Okay, so let's run that.
And there we go.
We should have this here.
So we see three by two, three rows, two columns.
That's fine.
And all values are zeros.
If we were, then you have all values ones.
And for the ones or the zeros like is similar to the ones like.
So you could take that as a simple exercise.
We then move forward.
We have this shape method right here where we told that this returns a tensor take note of that.
It returns a tensor containing the shape of the input tensor.
So, um, as we had seen before, we could obtain the shape of a tensor by simply, um, making use
of that tensor name dot shape.
Now, if we want to have an output like in our case now we want to have this output, um, tensor which
contains the shape of our tensor.
Then we could make use of this shape method from tensor flow.
So you see here we have the same four by two by three, but this is now another list.
Um, and then we have its shape and we also have its data type.
Obviously it's made of integers, so we shouldn't expect to have a float data type right here.
Another method which we could make use of is a rank method which simply returns the rank of a tensor.
So it takes an input and then returns its rank.
If you have a simple example right here where we have this three d tensor T, and then when you call
on the rank method, you see that we obtain the output, which is three.
So let's, um, put that out here.
Let's just paste it out here and test that quickly.
There we go.
As you could see, because the output is a zero dimensional tensor, the shape, it actually has no
shape, but you could see its value right here.
That's three.
Now, if we take out this s and take out this and then take out this other part here.
There we go.
We run this again.
We should have a rank of two this time around.
That's fine.
It's here.
The rank is two.
We now move to the size here, the size method, which returns the size of a tensor.
So you put in an input in the size method and it gives you the size of the tensor.
We have as usual on the example here, which we could copy.
But before running that, we could read this, um, note here where we told this returns A0D tensor
representing the number of elements in the input of type output type.
This is the output type here, which by default is Int32.
So let's get back here and paste this out and check out the size.
As you could see here, we have this size of 12 and that's because we have 12 different positions or
12 different elements in our tensor.
Now let's take this off again.
Take this off.
Um, take this off.
There we go.
Let's run that.
We should have six.
So that's it.
You see, we have six.
And here we could also specify this D type, um, let's say float.
Um, 32.
We get an error here.
Uh, got an unexpected keyword argument D type.
Now, getting back here, we see this is actually our type, not D type.
So let's get back here and then we have, um, out type.
So we have out type.
There we go.
Run that.
And as you could see right now, we have a float instead of an int.
The next step will take is creating our own.
Random tensors.
And that is essentially creating tensors which take up random values.
Now, in the case of TensorFlow, random, normal, our output values are going to be from or are going
to be drawn from a normal distribution.
And we are going to explain, at least at a high level, what this really means.
For now, let's just copy this out and get back to the code and run this and see what we get.
So right here, let's say we have random tensor.
There we go.
We need to specify the shape.
So we'll say let's take let's make a matrix a 2D tensor.
So let's say is three by two.
Now you see we have this mean value, standard deviation values which are being given right here by
default.
And we're going to look at what this actually means shortly.
The data type is two.
See, this is known name known.
Now let's run this or let's print this out and see what we get.
So here we have random tensor and there we go.
As you can see, we have this set of values which are all negatives.
And if you notice, they are very close to zero.
So here we have practically negative one about negative two, -0.3, very small number and -0.5 -0.87.
So these are numbers very close to seven.
Let's run this again.
So you see that we're able to randomly generate a matrix with this shape, with random values.
You see that it picks up different numbers.
This time around.
We have a mixture of positive and negative numbers.
But again, this numbers are very close to zero.
Now, what if we modify this mean so we modify this, mean we'll run this again, let's see what we
obtain.
You see that we have this numbers now which are instead close to 100.
And so what this tells us is that we could make use of this mean and the standard deviation to decide
on the kinds of random values we want to have here.
Now to better understand what is going on, let's consider this figure from this probability playground
by Adam Cunningham from the University of Buffalo.
As you had noticed in the code when we did TensorFlow random normal and the mean when we specify the
mean here the mean is this mu you have here.
When we specify the mean to be equal to zero, most of the values we had were surrounding zero.
And when we set this machine to 100, when we set it to 100, most of the values were surrounding 100.
Now, this curve you have here actually explains why.
So you have this curve right here, which is bell shaped.
And the idea here is that it permits us randomly pick values around the mean.
That's around zero.
So that's why you notice that at zero, we have the highest probability score here.
Our probability score is F of X.
So, um, for values around or values surrounding zero, that's this value surrounding zero.
There is much higher probability or chance.
Of them been picked as compared to values far away from zero.
So let's pick out these two values.
Let's say we have, um, let's say we want to pick out the two values 0.5, let's say 0.5, and we want
to pick out negative five.
You'll see from here that the probability of of us having negative five is practically zero.
That's almost zero.
But the probability of us having 0.5, as you could see from here, if you taking this middle, the
probability of us having 0.5 is about 0.35.
Now, if we change this value and take 100 as we did with the code, let's take a hundred.
We have that, um, 100.
Well, it looks like they've fixed this to six, so we cannot go above this.
We could play around this like this.
So you go from -6 to 6.
Okay, let's say the mean is six.
So we have the mean of six.
One thing you can notice is that now this, um, 0.5, as you could see, 0.5.
Let's take this off.
Um, 0.5 no longer has a probability of about 0.35 of being picked.
0.5 has the probability now of about zero of being picked, while negative five also still has a probability
of about zero of being picked.
But on the other hand, as you could see here, let's take this off.
You see that values like five have much higher probability of being picked seven, eight, six.
They now have much higher probabilities of being picked.
Now, this means that if this was a hundred or if we were able to get to a hundred, then we'll be values
like 97 or 98, 99, 100, 101, 102.
And this explains why when we run this code with this mean we had values surrounding 100, and that's
simply because those values surrounding the mean have um higher probabilities of being picked.
Now let's take this back to zero and then talk about the standard deviation.
So we have the zero there we go to get back to zero.
And now let's talk about the standard deviation.
But before getting into any, um, explanations, let's modify this.
Let's say we take ten here.
Okay?
It looks like the max is fixed at 2.5.
Okay.
So let's, let's say we have that 2.5.
One thing you can notice is we still have this mean at zero.
We still have our mean at zero.
Does it make sense because we haven't changed this but our bell curve.
Um.
Shape now appears wider.
So an increase in sigma.
Sigma here is what we call the standard deviation.
So it's what we call STD dev in the code.
So we had the mean and the standard deviation.
So sigma the standard deviation, the Sigma Square is the variance.
So Sigma Square is the variance.
Anyway, what we're trying to say here is an increase in Sigma will make this curve wider and a decrease.
Let's decrease sigma.
You see, a decrease in sigma makes the curve thinner and narrower.
Now what this implies is that if we have, let's say, let's get back to this.
If we have Sigma Square as 2.5, there are much higher chances now that we could, um, randomly select
negative five as compared to before.
So if this is negative five here, you see there's a slightly higher probability of negative five and
peaked as compared to when we reduced this.
You see, when we reduce this, um, you see negative five years, practically zero.
But when we increase, see negative five is at least this time around having some negligible value.
And so this is essentially the role that standard deviation plays.
Now if we reduce this again, we find that even 0.5 because this is 0.5 around here, even 0.5, let's
take this off.
Even 0.5, which used to have a probability of about 0.35 of occurring now has almost no chance of being
picked.
Let's increase it back and set it back to zero.
Okay.
And so that is it.
At this point, we could modify this.
We could take this to six and then take this to 2.5.
And you see that we could take values Now between zero, see, we go from zero to about, um, 11.
With that said, we will then look at the uniform distribution or how to generate random numbers or
random values drawn from a uniform distribution.
So again, we'll just copy this out and then get back to the code.
We will paste this here.
There we go.
We have the shape.
Let's pick, um, this, uh, one.
Okay.
And then minimum value zero.
And now we have maximum value.
So you see that unlike here, where we had the minimum, the mean and the standard deviation, now we
have instead of a minimum value and a maximum value.
So let's, let's, let's leave, leave it at this.
And then let's say we have random tensor, random tensor.
Okay?
So let's print this out.
Let's print out our random tensor.
There we go.
We have random tensor.
Let's increase this so we have many more values.
Five run that.
Okay.
You see, we have this values.
Now let's let's say we change this max value and say it's um.
880 or let's say eight.
Okay, let's say eight.
Let's run that.
And what do you notice now is you have much larger values.
Well, values between 0 and 8.
But, um, before the values we're getting were values ranging between 0 and 1.
Now, this tells us that most probably this maximum value by default is one.
So here it is, default to one.
You could always make use of the documentation whenever you're in doubt.
So let's get back here.
You see, we will take this to 100 and then see what we get.
You see, we have this values now between 0 and 100.
Now the question you may be asking yourself is what then is the difference between this uniform and
this normal distribution?
So let's get back again here, um, in our probability playground and then let's pick out our uniform.
So as you could see, your many other probability distributions.
But we are going to focus on the normal distribution and the uniform distribution.
So we get into the uniform distribution and here is what we get.
So we have A and B Now this is like our main value, which we saw in the code, and this is like our
max Val.
So when we say meanwhile, negative one, max, Val one, obviously our values will fall in this range.
Now by default, this is zero and this is one on TensorFlow.
So, um, that's why you saw the values ranging between 0 and 1.
Now, as the term goes, it's actually uniform.
So this means that all this values here have equal chances or probabilities of being picked.
And so unlike the normal distribution where we would have something like this.
Something like this.
Now we have this square instead or this rectangle.
And so simply here, all we're doing is picking the range of values which we want to have or which we
want to be outputted so we could get here, increase this.
We you cannot you cannot the mean cannot pass.
The cannot be greater than the max.
So that makes sense.
Let's reduce this, reduce that.
So from -4 to 4, you see, we take all the values.
Well, that's it.
You see, there we go.
We go from -1 to 2.
That's it.
Now, one great thing is also the fact that we could modify this and have it.
So let's run this and see what we get.
You see, we have only integers now.
Now let's say we had known known.
Let's run that.
You see, we have an error.
Must specify a max val in the case where the data type is integer.
So this actually, um, written out here in the documentation.
So you can see here now that you need to have this max.
Val So let's change that to, let's say 1000.
So you will get values ranging between 0 and 1000.
So we have five values here from the shape.
We could change this, let's say five by five, and then all those values range between 0 and 1000.
Another argument which we haven't spoken of so far is this seed argument.
And here we told that this seed argument when used in combination with TensorFlow random set seed,
will be able to create a reproducible sequence of tensors across multiple calls.
And so in cases where we want to produce reproducible experiments, we want to set this global seed
value and also the seed argument value in this uniform or let's say normal function.
So let's go ahead and copy this out.
We'll get back to the code.
There we go.
Let's just run this right here.
Let's take off some parts and print this out.
So we print this out.
Then we modify the shape and the max values so we have exactly the same value for the seed here, which
is ten.
And then here we set this global seed to five.
Let's run this.
You see it outputs four, three, one, four, three, two, one, one, one, and one, three, three.
Now let's create another cell.
Let's copy this.
There we go.
Paste this out here.
And you see, we have the same global seed, and then we have the seed of ten.
Now let's run this again.
And as you could see, we have exactly the same output as this one.
See?
Four, three, 1431432, four, three, two, one, 1111, one and one three, three.
Now, obviously modifying this and taking for example, one gives us something different.
But if we take ten again, you see, we should have exact same output.
Now you also see that here when we take this off, if we take this off and rerun this cell, you see
we have different outputs.
But when we get back here, let's let's run this again.
See, we have another set of different outputs.
But when we take this run that you see, we have exact same output we had already.
And now if you want to have more details about certain seeds, you could always check out this, the
documentation.