Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- for ep in range(eps):
- print('Ep {:3d}/{:3d}...'.format(ep+1,eps))
- alpha = alpha * np.exp(-0.2 * ep)
- for j in range(count):#random.permutation(count):
- x = inputs[:, j]
- y = []
- for i in range(self.dim_out):
- #print(j)
- #print(y[j])
- y_i = self.weights[i] @ x + (0 if i == 0 else self.u[i][:i] @ np.array(y).T)
- self.weights[i] += alpha * y_i * (x - y_i * self.weights[i])
- norm = np.linalg.norm(self.weights[i])
- if norm != 0:
- self.weights[i] /= norm
- self.u[i] += (- alpha * y_i * (y + y_i * self.u[i]) if i > 0 else 0)
- norm = np.linalg.norm(self.u[i])
- if norm != 0:
- self.u[i] /= norm
- y.append(y_i)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement