4 A] Explain briefly about the gradient descent algorithm.
Gradient Descent Algorithm
Gradient descent is an optimization algorithm used to minimize the cost function in machine learning models, particularly for training models like linear regression, neural networks, etc. The algorithm works by iteratively adjusting the model parameters in the direction of the steepest decrease of the cost function, based on the gradient (partial derivative) of the cost function with respect to each parameter.
Steps of Gradient Descent:
- Initialize Parameters: Start with initial values for the parameters (weights, biases, etc.).
- Compute Gradient: Calculate the derivative (gradient) of the cost function with respect to the parameters. This indicates the direction and rate of the steepest increase.
- Update Parameters: Adjust the parameters in the opposite direction of the gradient to reduce the cost. The update rule is: \theta = \theta - \alpha \frac{\partial J(\theta)}{\partial \theta}
where:- \theta: Parameter to update
- \alpha: Learning rate (step size)
- \frac{\partial J(\theta)}{\partial \theta}: Gradient of the cost function
- Repeat: Continue updating until the cost function converges to a minimum or meets a stopping criterion.
Key Points:
- The learning rate controls the size of each step. Too large may overshoot; too small slows convergence.
- Variants include Batch Gradient Descent, Stochastic Gradient Descent (SGD), and Mini-batch Gradient Descent.
1 Cost Functions
Cost functions (also called loss functions) measure the difference between the model’s predictions and the actual values. The goal of gradient descent is to minimize the cost function.
1.1 Learning Conditional Distributions with Maximum Likelihood
In machine learning, maximum likelihood estimation (MLE) is a method to estimate the parameters of a probabilistic model by maximizing the likelihood of the observed data. Conditional distributions describe the probability of a target variable given certain conditions or inputs. The goal is to find model parameters that maximize the conditional likelihood of the target variable.
1.2 Learning Conditional Statistics
Learning conditional statistics involves estimating certain parameters (mean, variance, etc.) of a distribution conditioned on observed data. This can be done by minimizing a cost function that measures the error between the predicted statistics and actual data.
2 Output Units
Output units are the final layer of a neural network or model that transforms the internal representations into the desired prediction or output.
2.1 Linear Units for Gaussian Output Distributions
In the case of Gaussian (normal) distributions, linear output units are used in the output layer. These units predict a continuous value, and the cost function is typically the mean squared error (MSE) between the predicted and actual values.
2.2 Sigmoid Units for Bernoulli Output Distributions
For binary classification problems, sigmoid output units are used. The sigmoid function maps the output to a range between 0 and 1, making it suitable for binary outcomes (e.g., yes/no, 0/1). The cost function is often the binary cross-entropy loss.
2.3 Softmax Units for Multinoulli Output Distributions
Softmax units are used for multi-class classification problems, where the output is a probability distribution over multiple classes. The softmax function converts raw model scores into probabilities that sum to 1, making it useful for problems with more than two possible outcomes. The cost function is typically categorical cross-entropy.
2.4 Other Output Types
Other output units could include custom activation functions or layers depending on the problem being solved, such as regression outputs with non-Gaussian distributions or complex structured data.
These output units and cost functions are essential for designing models that fit specific types of data and tasks, from binary classification to multi-class classification and regression.