-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
[Term Entry] Neural Networks ai gradient descent #5785
[Term Entry] Neural Networks ai gradient descent #5785
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @PragatiVerma18 , thank you for contributing to Codecademy Docs, the entry is nicely written! 😄
I've suggested a few changes, could you please review and modify those at your earliest convenience? Thank you! 😃
@@ -0,0 +1,112 @@ | |||
--- | |||
Title: 'Gradient Descent' | |||
Description: 'Gradient Descent is an optimization algorithm used in machine learning and neural networks to minimize a cost function by iteratively moving towards the minimum using the gradient of the function.' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The description should not be more than 160 characters
- 'path/data-science' | ||
--- | ||
|
||
**Gradient Descent** is an optimization algorithm commonly used to minimize a cost function in machine learning and neural networks. The goal of gradient descent is to find the optimal parameters (weights) for a model that minimizes the error or loss function. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
**Gradient Descent** is an optimization algorithm commonly used to minimize a cost function in machine learning and neural networks. The goal of gradient descent is to find the optimal parameters (weights) for a model that minimizes the error or loss function. | |
**Gradient Descent** is an optimization algorithm commonly used in machine learning and neural networks to minimize a cost function. Its goal is to iteratively find the optimal parameters (weights) that minimize the error or loss. |
|
||
**Gradient Descent** is an optimization algorithm commonly used to minimize a cost function in machine learning and neural networks. The goal of gradient descent is to find the optimal parameters (weights) for a model that minimizes the error or loss function. | ||
|
||
In the context of neural networks, gradient descent adjusts the model’s parameters by computing the gradient (or derivative) of the cost function with respect to each parameter. The algorithm then updates the parameters in the direction that reduces the cost. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the context of neural networks, gradient descent adjusts the model’s parameters by computing the gradient (or derivative) of the cost function with respect to each parameter. The algorithm then updates the parameters in the direction that reduces the cost. | |
In neural networks, gradient descent computes the gradient (derivative) of the cost function with respect to each parameter. It then updates the parameters in the direction of the negative gradient, effectively reducing the cost with each step. |
| Type | Description | | ||
| ------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| **Batch Gradient Descent** | Uses the entire dataset to compute the gradient and update the weights. Typically slower but more accurate for large datasets. | | ||
| **Stochastic Gradient Descent (SGD)** | Uses a single sample to compute the gradient and update the weights. Faster, but the updates are noisy and can lead to fluctuations in the convergence path. | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| **Stochastic Gradient Descent (SGD)** | Uses a single sample to compute the gradient and update the weights. Faster, but the updates are noisy and can lead to fluctuations in the convergence path. | | |
| **Stochastic Gradient Descent (SGD)** | Uses a single sample to compute the gradient and update the weights. It is faster, but the updates are noisy and can cause fluctuations in the convergence path. | |
theta = theta - learning_rate * gradient_of_cost_function | ||
``` | ||
|
||
- `theta`: The parameter (weight) of the model. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- `theta`: The parameter (weight) of the model. | |
- `theta`: The parameter (weight) of the model that is being optimized. |
|
||
- `theta`: The parameter (weight) of the model. | ||
- `learning_rate`: A hyperparameter that controls the step size. | ||
- `gradient_of_cost_function`: The gradient (derivative) of the cost function with respect to the parameters. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- `gradient_of_cost_function`: The gradient (derivative) of the cost function with respect to the parameters. | |
- `gradient_of_cost_function`: The gradient (derivative) of the cost function with respect to the parameters, indicating the direction and magnitude of the change needed. |
theta = initial_value # Parameters (weights) | ||
learning_rate = value # Learning rate |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
theta = initial_value # Parameters (weights) | |
learning_rate = value # Learning rate | |
theta = initial_value # Model Parameters (weights) | |
learning_rate = value # Learning rate (step size) |
# Repeat until convergence | ||
for i in range(iterations): | ||
# Calculate the gradient of the cost function | ||
gradient = compute_gradient(X, y, theta) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gradient = compute_gradient(X, y, theta) | |
gradient = compute_gradient(X, y, theta) # Gradient calculation |
# Cost function (Mean Squared Error) | ||
def compute_cost(X, y, theta): | ||
m = len(y) | ||
cost = (1/(2*m)) * np.sum((X*theta - y)**2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cost = (1/(2*m)) * np.sum((X*theta - y)**2) | |
cost = (1/(2*m)) * np.sum((X*theta - y)**2) # The cost function for linear regression |
Hey @mamtawardhani, I am done with the changes. Please review. Thanks. 🫡 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for contributing to Codecademy Docs @PragatiVerma18 😄
The entry looks good to be merged! 🚀
👋 @PragatiVerma18 🎉 Your contribution(s) can be seen here: https://www.codecademy.com/resources/docs/ai/neural-networks/gradient-descent Please note it may take a little while for changes to become visible. |
Description
Add a new term entry in the AI concept for neural-network: gradient descent.
Issue Solved
Closes #4526
Type of Change
Checklist
main
branch.Issues Solved
section.