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

Cost function in backpropogation section is confusing and possibly incorrect. #144

Open
RylanYancey opened this issue Nov 3, 2023 · 1 comment

Comments

@RylanYancey
Copy link

Wikipedia defines the cost function MSE as follows:
image

Yet, the ml cheatsheet uses the following formulas in the backpropogation section.
image

This is particularly confusing since the Linear Regression and Gradient Descent section defines it correctly:
image

@sprakshith
Copy link

The factor of (1/2) is often included for mathematical convenience. When you take the derivative of the cost function to perform gradient descent (a common optimization algorithm), the (1/2) cancels out when computing the gradient, simplifying the expressions and computations.

Also I believe that this cost function is just for an instance and they have not yet taken the mean in this case:

image

Equation for Mean Squared Error with (1/2) multiplied for convenience: $$\frac{1}{2n} \sum_{i=1}^{n} \left( \hat{y}^{(i)} - y^{(i)} \right)^2$$

And then after taking the differentiation: $$\frac{1}{n} \sum_{i=1}^{n} \left( \hat{y}^{(i)} - y^{(i)} \right) \cdot x^{(i)}$$

PS: If I am wrong please correct me, 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

2 participants