Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2025 Foundation Course
NEET 2025 Foundation Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
0 votes
60 views
in Artificial Intelligence (AI) by (114k points)
What is gradient descent?

Please log in or register to answer this question.

1 Answer

0 votes
by (114k points)

Gradient descent is an optimization algorithm used to minimize the cost or loss function in machine learning models. It iteratively adjusts the model's parameters by taking steps proportional to the negative gradient of the cost function. The algorithm continues to update the parameters until convergence is reached or a maximum number of iterations is reached.

Example code for gradient descent in linear regression:

# Assuming X and y are the feature matrix and target vector, respectively
# Initialize parameters
theta = np.zeros(X.shape[1])

# Define learning rate and number of iterations
learning_rate = 0.01
num_iterations = 1000

# Perform gradient descent
for i in range(num_iterations):
    # Calculate predictions
    predictions = np.dot(X, theta)
    
    # Calculate error
    error = predictions - y
    
    # Calculate gradient
    gradient = np.dot(X.T, error) / len(y)
    
    # Update parameters
    theta -= learning_rate * gradient
 

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...