Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

theta[0] is caculated twice in per gradient_step at LinearRegression #17

Open
alqbib opened this issue Mar 31, 2019 · 0 comments
Open

Comments

@alqbib
Copy link

alqbib commented Mar 31, 2019

Vectorized version of gradient descent.

theta = theta * reg_param - alpha * (1 / num_examples) * (delta.T @ self.data).T

We should NOT regularize the parameter theta_zero.

theta[0] = theta[0] - alpha * (1 / num_examples) * (self.data[:, 0].T @ delta).T

the first code line ,theta include theta[0].
so I think can write like this:
theta[0] -= alpha * (1 / num_examples) * (self.data[:, 0].T @ delta)
theta[1:] = theta[1:] * reg_param - alpha * (1 / num_examples) * (self.data[:, 1:].T @ delta)

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant