We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f2438a1 commit 6472fd9Copy full SHA for 6472fd9
linear_regression_class/gd.py
@@ -0,0 +1,25 @@
1
+import matplotlib.pyplot as plt
2
+
3
+lr = 1e-2
4
+x1 = 5
5
+x2 = -5
6
7
+def J(x1, x2):
8
+ return x1**2 + x2**4
9
10
+def g1(x1):
11
+ return 2*x1
12
13
+def g2(x2):
14
+ return 4*x2**3
15
16
+values = []
17
+for i in range(1000):
18
+ values.append(J(x1, x2))
19
+ x1 -= lr * g1(x1)
20
+ x2 -= lr * g2(x2)
21
+values.append(J(x1, x2))
22
23
+print(x1, x2)
24
+plt.plot(values)
25
+plt.show()
0 commit comments