Created
April 10, 2020 06:59
-
-
Save Alakhator/8fd355915cb3d7bf3ad7c0d5c0809dbe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for (int i = 0; i < 20; i ++) { // since there are 5 values and we want 4 epochs so run for loop for 20 times | |
int idx = i % 5; //for accessing index after every epoch | |
double p = b0 + b1 * x[idx]; //calculating prediction | |
err = p - y[idx]; // calculating error | |
b0 = b0 - alpha * err; // updating b0 | |
b1 = b1 - alpha * err * x[idx];// updating b1 | |
cout<<"B0="<<b0<<" "<<"B1="<<b1<<" "<<"error="<<err<<endl;// printing values after every updation | |
error.push_back(err); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment