import numpy as np
import matplotlib.pyplot as plt
x = np.arange(0.,10.,0.2)
m = len(x)
x0 = np.ones(m)
input_data = np.vstack([x0,x]).T
target_data = 2*x+5+np.random.randn(m)
loop_max = 1000
epsilon = 1e-3
np.random.seed(0)
theta = np.random.randn(2)
alpha = 0.001
error = np.zeros(2)
count = 0
finish = 0
while count < loop_max:
count+=1
sum_w = np.zeros(2)
for i in range(m):
for j in range(2):
sum_w[j] += (target_data[i]-theta.dot(input_data[i,:]))*(-input_data[i,j])
theta = theta - (