Skip to playerSkip to main content
  • 10 minutes ago

Category

📚
Learning
Transcript
00:00before you start writing your code, you can first go change the runtime type and then
00:05save whichever accelerator that you require as per your problem statement and click on
00:11save.
00:12So this is a simple you know basics that are required for you.
00:17Now here you can see how much you know what is the configuration that is given to you.
00:22You can able to see here the RAM and so much of RAM that is allotted and this much of
00:28disk
00:28space that is allotted for running this particular program.
00:32So this is what is the basic basics of Google Collab, with this basics we will explore more
00:40about this as and when we deal with other hands on, we will also learn how to import the data,
00:48how do you upload if there is you know you have a large amount of data, you do not want
00:53to store it in the drive, you want to use it directly from the link, you have you have an
00:57online link where there is a data, all that we will see as and when that part of a concept
01:02that part of an hands on concept is taught to you.
01:05So with this we will quickly look into an single layer perception.
01:10For this single layer perception the data that we are taking is this, I hope you remember
01:17we have solved a problem.
01:18So, you can have this solved problem with you, so that you can able to relate the answer step
01:26by step when you have implemented it using python.
01:29So, here we have taken x1 and x2 as the value 1 and 2 and the target value is 1
01:35and then we
01:36have weights initialized as 0.2 and minus 0.5, bias 0.1 and learning rate 0.1.
01:43So, these are the values that we had taken to solve a problem.
01:48What is the very first step?
01:50You go back once again and then recall the perception learning rule, the very first step
01:56is you have to initialize certain parameters.
02:00So, what are the different parameters that we are initializing?
02:02We require weights, we require bias and then we require a learning rate and here the input
02:07what we are taking is 1 and 2 and the target value is 1.
02:13So, the very first step if there are any necessary packages that are required for us, we have to
02:18import those packages.
02:20Since it is a simple perceptron model, we are dealing with some numerical operations, we are
02:25doing x into wf and we are adding it to bias, we are doing a simple basic arithmetic operations.
02:34Therefore, we are importing numpy as np.
02:38So, once you write this, execute a cell, then you will be initializing all the parameters
02:44that are required.
02:45So, we have defined an x and we have taken it as an array, list of elements and then we
02:53have taken an target value as 1 and then the weight, we have taken the 2 weights, this is
03:00a bias and then the learning rate.
03:02So, you can execute it either by using shift enter or we can execute it by you know pressing
03:09on this icon.
03:10So, the next step, I hope you can remember we had repeated that particular problem almost
03:17for 3 times to get the correct parameters.
03:20So, the same thing you have repeated again and again right.
03:23What was the first step?
03:25You have calculated, you have first you have to calculate x into wf, x1 plus w1 plus x 2
03:30into w2 plus bias.
03:33So, that is what is the first step that we are doing.
03:36So, it is written in this way.
03:39So, we are, it is a dot product between x and wf and we are adding a bias and because
03:46it is a dot product, it is a part of numerical numpy.
03:49Therefore, we are writing np dot dot and once we calculate the net input that is once we
03:56calculate a z, is it not we are passing it to an activation function.
04:00What is an activation function?
04:02Step activation function or a threshold activation function, if the value is greater than 0, then
04:09the answer is 1, else the answer is 0.
04:12So, whatever is the resultant value, if this value is greater than 0, then the output will
04:18be 1, otherwise the output will be 0.
04:20Then, this is how you are getting the predicted value.
04:24Once you get the predicted value, we calculate the error.
04:27What is the formula to calculate the error?
04:30If you remember, it is a target minus computed value.
04:33So, how do we get the target?
04:36Target we have already defined as y.
04:37So, y minus y predict.
04:39So, it is target minus computed y minus y predict.
04:44Once this is done, we want to visualize what is our z, what is the predicted value and what
04:51is the error?
04:52So, these 3 print statements are used to visualize the values that we have obtained.
04:58Now, once we calculate the error, what is the next step?
05:03Is it not we update?
05:04How is, what is the formula to update?
05:07It is W is W plus learning rate eta into the error target minus computed into its associated
05:16input x.
05:17So, this is how you update the W and this is the line which is used to update the bias.
05:24Once we update W and bias, we are going to print those values.
05:29This is for one epoch.
05:32This is for one you know epoch.
05:36Now, you will be repeating this for 3 different.
05:39You had repeated the same operation for 3 different times, right?
05:43So, you instead of writing the same code 3 different, you are running, you are putting
05:48it into a for loop.
05:49So, here I am running it by showing this.
05:52So, we can able to see, I want you to compare this with the answer that you have obtained
05:59by solving this.
06:01In the previous session, we had solved the entire problem.
06:04So, the net weight what we have obtained is minus 0.7 and the predicted value is 0, the
06:09error is 1.
06:10And by updating the weights, we are getting a new weights and a new bias.
06:14Then you have repeated, you had repeated the same problem second time.
06:18When you had repeated, you got the z value as a minus 0.10, the predicted value is 0, error
06:26is 1.
06:27And when with these, when you updated, we got the values 0.4 and minus 0.1.
06:33And this is the updated bias.
06:35Then again we had run once again to because still we are getting an error here.
06:41So, when we repeated this process again, the z value what we had got was 0.5.
06:46This is the predicted value and this is the error.
06:49And these are the updated weights and this is the updated bias.
06:54So, this is however, the problem is being solved on a similar lines, the implementation is also
07:02been done.
07:03This is a simple single layer perception implementation one.
07:08And this is when a new data is passed, the new data if you remember during the testing
07:13time, we were passing a new data.
07:15So, when we pass a new data here.
Comments

Recommended