0% found this document useful (0 votes)
10 views33 pages

Deep Feedforward Networks Overview

Uploaded by

chandana6323
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views33 pages

Deep Feedforward Networks Overview

Uploaded by

chandana6323
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Module2

Deep Feedforward Networks: Gradient-Based Learning, Hidden Units, Architecture


Design, BackPropagation. Regularization Introduction: Parameter Norm Penalties, Norm
Penalties as Constrained Optimization.

Deep Feedforward Networks:


A feedforward neural network is a type of artificial neural network where
information flows in one direction, from the input layer to the output layer, without
any feedback loops. It's like a series of interconnected nodes, or neurons, organized
in layers.

Deep feedforward networks, also known as multilayer perceptrons (MLPs) or


simply feedforward neural networks

Key Characteristics of Deep Feedforward Networks:

[Link]/Key Components:
1. Input Layer: Receives the input data.
2. Hidden Layers: One or more layers between the input and output layers.
These layers extract and transform features from the input data.
3. Output Layer: Produces the final output, which can be a classification or
regression prediction.
4. Neurons: Each neuron in a layer receives inputs from the previous layer,
performs a weighted sum of these inputs, applies an activation function, and
passes the result to the next layer.
5. Activation Functions: Non-linear functions that introduce non-linearity into
the network, allowing it to learn complex patterns. Common activation
functions include ReLU (Rectified Linear Unit), sigmoid, and tanh
a.

b.

[Link] it Works:
Input: The input data (e.g., features of an image) is fed into the input layer.
Propagation: The input data is propagated through the network, layer by
layer.

Each neuron in a layer calculates its output using the following formula:

output = activation_function(∑(weights * inputs) + bias)

where:

 weights are the parameters (or weights) of the neuron.


 inputs are the outputs of the previous layer.
 bias is a constant term added to the weighted sum.

 activation_function is a non-linear function like ReLU, sigmoid, or tanh.


Output: The final output is produced by the output layer, which typically
uses a suitable activation function for the task (e.g., sigmoid for
classification, linear for regression).

[Link] and Training:


 Forward Pass: During the forward pass, inputs are passed through
the network, layer by layer, with each layer applying a weighted sum
and activation function.
 Loss Function: After the forward pass, the loss function computes the
error between the predicted output and the actual target values.
 Backpropagation: In the backward pass, the error is propagated back
through the network,. network's weights are then updated to reduce
error

[Link] Optimization:
 Gradient Descent: The most common optimization algorithm used in
deep feedforward networks.
[Link]:
 "Deep" refers to having multiple hidden layers.
Training Process:
 Initialize weights randomly.
 Forward pass to compute the predictions.
 Compute the loss using a suitable loss function (e.g.,
cross-entropy for classification).
 Backpropagate the error to compute gradients.
 Update weights using an optimization algorithm (e.g.,
gradient descent).
 Repeat the process for multiple iterations (epochs) until the
model converges (i.e., the loss function reaches a minimum).
Gradient-Based Learning:
 Neural Network Training:
 Training a neural network is similar to training any other machine learning
model using gradient descent.
 Non-linearity in Neural Networks:
 The biggest difference between neural networks and linear models is the
non-linearity of neural networks.
 Non-linearity makes loss functions non-convex, meaning they have multiple
minima and can make optimization more difficult.


 Optimization and Convergence:
 Neural networks are usually trained using iterative, gradient-based
optimizers to minimize the cost function, which is not as straightforward as
solving linear equations in models like linear regression.
 Convex optimization methods (like those used in logistic regression or
SVMs) guarantee global convergence, but this is not the case with non-
convex problems.
 Stochastic Gradient Descent (SGD):
 SGD is applied to non-convex loss functions, and unlike convex problems, it
does not guarantee convergence to a global minimum.
 The convergence of SGD can be sensitive to various factors, such as the
initialization of parameters.
Gradient-based Learning for neural networks:

 Initialization:
 Weights: For feedforward neural networks, it is common to initialize all
weights to small random values.
 Biases: Biases can be initialized to zero or small positive values.
 Training Phase:
 During the training phase, gradient descent is used to minimize the cost
function by updating the weights based on the gradient of the loss.
 Comparison with Other Models:
 Linear regression and SVM models can use gradient descent for larger
training sets. However, the gradient calculation in neural networks is more
complex due to the non-linear structure but can still be computed efficiently.
 Gradient Computation:
 The gradient is computed using the back-propagation algorithm, which
calculates the gradient of the loss function with respect to each weight in the
network.

 Input: x1 is the input value to the neuron.


 Weights: w1 and w2 are the weights associated with the input connections.
 Activation Function: σ represents the activation function applied to the
weighted sum of inputs.
 Output: ŷ is the output of the neuron.
 Gradients: dw1 and dw2 are gradients representing the rate of change of the
cost function with respect to the weights w1 and w2, respectively.
 dz: This likely represents the gradient of the cost function with respect to the
weighted sum z before the activation function is applied.
The gradients dw1 and dw2 are used to update the weights w1 and w2 during
training, with the goal of minimizing the error between the predicted output ŷ and
the actual target value.

Steps to Apply Gradient-Based Learning:


 For best gradient Choose the best values for the below:
c. The cost function.
d. The form of the output units.
e. The optimizer for updating weights.
Cost Function
A cost function, also known as a loss function or objective function, is a
crucial component in gradient-based learning. It quantifies the error between
a model's predicted output and the actual target. The goal of the learning
process is to minimize this cost function.
Choosing the Cost Function:

 In gradient-based learning, the cost function must be chosen to define how


well the neural network performs. Additionally, the output structure of the
network must be determined.

Total Cost Function:

 The total cost function is what is minimized during the training of a neural
network. It measures the difference between the predicted output and the
actual output (labels).

Modern Neural Networks:

 Most neural networks use maximum likelihood for training, and the cost
function in this case is the negative log-likelihood, often referred to as
cross-entropy. It measures the divergence between the training data
distribution and the model's output distribution.

Gradient of the Cost Function:

 For effective learning, the gradient of the cost function should be large
enough to drive meaningful updates to the weights during training. If the
gradient becomes too small, learning becomes slow or may stop altogether.

Saturation of Functions:

 If activation functions (e.g., sigmoid, tanh) saturate, they can become very
flat, leading to vanishing gradients (very small gradient values). This can
significantly hinder learning as the model stops adjusting the weights
meaningfully.

Negative Log-Likelihood:

 The negative log-likelihood helps to avoid saturation problems in many


models, making sure that the gradient remains useful for updating the model
parameters during training.

Maximum Likelihood Estimation (MLE)


Objective:

 To find the parameter values (θ) that maximize the likelihood of observing the given data.
 P(D|θ): This represents the likelihood of the data given the model
parameters.
 ∑: The summation symbol indicates that we're summing over all data points.
 m: The total number of data points.
 y_i: The actual target value for the i-th data point (either 0 or 1).
 ŷ_i: The predicted probability of the i-th data point belonging to class 1.
 log(): The natural logarithm function.

Interpretation:

The equation calculates the log-likelihood by summing the contributions from each
data point.

Choosing Output Units


Output Units in the context of Artificial Neural Networks (ANNs) refer to the
neurons or nodes in the output layer, where the final predictions or results are
produced after the data has passed through the network.

The number and type of output units depend on the specific task or problem the
neural network is designed to solve.

Types of Output Units Based on the Problem:

1. For Classification Problems:


a. Single Output Unit: Used when there are only two possible classes
(binary classification). The output is usually a probability between 0
and 1, generated by an activation function like sigmoid.
b. Multiple Output Units: Used for multiclass classification problems
(e.g., classifying handwritten digits). Each output unit corresponds to
one class, and the network outputs a probability distribution over all
possible classes, often using a softmax activation function.

Example:

c. For a binary classification task (e.g., "Is this spam?"), the network
might have one output unit that produces a probability.
d. For a multiclass task (e.g., digit classification 0-9), the network could
have 10 output units (one for each digit).
2. For Regression Problems:
a. Single Output Unit: In regression tasks (e.g., predicting house
prices), the output unit typically does not use an activation function
like softmax or sigmoid and directly outputs a continuous value (real
number).
b. Multiple Output Units: In cases where multiple continuous values
need to be predicted simultaneously, the output layer can have
multiple units, each predicting a different value.

Example:

c. In predicting house prices, the network might have one output unit
representing the predicted price.
d. For multi-output regression (e.g., predicting several attributes like
weight and height), there could be multiple output units, one for each
attribute.

Activation Functions for Output Units:


 Sigmoid: Common for binary classification, the output is in the range [0, 1].
 Softmax: Common for multiclass classification, it normalizes the outputs
into a probability distribution over multiple classes.
 Linear: Common for regression, the output is a real number without any
restriction on its range.

[Link] Output Units

 Description: The output is directly proportional to the weighted sum of


inputs.
 Activation Function: No activation (identity function).

 Use Case: Regression tasks where the output is continuous (e.g.,


predicting house prices).
 Advantages: Suitable for predicting unbounded values.
2. Sigmoid Output Units

 Description: Outputs values between 000 and 111 (sigmoid squashing


function).
 Activation Function:

 Use Case: Binary classification tasks or probabilistic outputs.


 Advantages: Useful when the output needs to represent probabilities.
 Limitation:
o Saturation (gradient vanishing) for extreme inputs.
o Not suitable for multi-class problems.

3. Softmax Output Units

 Description: Converts outputs into probabilities that sum to 111 across


multiple classes.
 Activation Function:

 Use Case: Multi-class classification tasks (e.g., classifying images into


categories).
 Advantages: Outputs a probability distribution over all possible classes.
 Notes:
o Works well when used with cross-entropy loss.

4. Tanh Output Units

 Description: Outputs values between −1-1−1 and 111 (hyperbolic tangent


function).
 Activation Function:
 Use Case: Regression tasks requiring bounded output or when outputs can
have negative values.
 Advantages:
o Zero-centered output (faster convergence in some cases).

5. ReLU (Rectified Linear Unit) Output Units

 Description: Outputs are either the input or zero.


 Activation Function:

 Use Case: Rarely used in output layers (mostly used in hidden layers), but
can handle specific unbounded positive outputs in regression.

6. Log-Softmax Output Units

 Description: A numerically stable version of softmax used in conjunction


with the negative log-likelihood loss.
 Activation Function:

 Use Case: Multi-class classification tasks, often in PyTorch implementations


for stability.
 Advantages: Prevents numerical overflow issues.

7. Exponential Output Units

 Description: Outputs are exponential transformations of inputs.


 Activation Function:

 Use Case: Modeling outputs that are strictly positive, e.g., in Poisson
regression for count data.
8. Softplus Output Units

 Description: Smooth approximation of ReLU, outputs are strictly positive.


 Activation Function:

Use Case: Predicting positive outputs, such as rates or variances.

Choosing optimizer
An optimizer in machine learning refers to the algorithm or method used to update
the model's parameters (like weights) during training in order to minimize the loss
function. The goal of an optimizer is to find the optimal values of these parameters
that minimize the error between the model's predictions and the actual target
values.
Key Types of Optimizers:

Gradient Descent:

 The most fundamental optimization algorithm.


 It computes the gradients of the loss function with respect to the model
parameters and updates the parameters in the opposite direction of the
gradients.
 Types:
o Batch Gradient Descent: Uses the entire dataset to compute the
gradient.
o Stochastic Gradient Descent (SGD): Updates the parameters for
each data point individually.
o Mini-batch Gradient Descent: A compromise between batch and
stochastic, updating the parameters using small batches of data.

Adam (Adaptive Moment Estimation):

 Combines RMSProp with momentum by keeping an exponential moving


average of the gradient and the squared gradient.
 Popular due to its adaptability and efficiency across a wide range of
problems.
 Requires minimal tuning compared to other optimizers and performs well in
practice.
Other optimizers:

Hidden Units
Each hidden unit applies a weighted sum of its inputs, followed by an
activation function (e.g., ReLU, sigmoid, or tanh) to introduce non-
linearity, allowing the network to learn more complex patterns.
1 Rectified Linear Units and Their Generalizations

Rectified Linear Unit (ReLU)

Definition

The ReLU activation function is defined mathematically as:

This means that if the input x is positive, the output is x; otherwise, the output is 0.
 Key Properties:
 Non-linearity: ReLU introduces non-linearity into neural networks, which is
essential for learning complex patterns.
 Sparsity: Many neurons in a ReLU network may have zero activations, which
can improve computational efficiency.
 Dying ReLU Problem: One potential issue with ReLU is the "dying ReLU"
problem, where neurons can become stuck in a state where they always
output 0. This can reduce the network's learning capacity. Techniques like
Leaky ReLU and Parametric ReLU can help mitigate this problem.
 Advantages of ReLU:
 Faster convergence: ReLU can often lead to faster training compared to
other activation functions like sigmoid or tanh.
 Reduced vanishing gradient problem: ReLU helps to alleviate the
vanishing gradient problem, which can occur in deep neural networks.

2. Logistic Sigmoid and Hyperbolic Tangent


Logistic Sigmoid and Hyperbolic Tangent (tanh) are two widely used
activation functions in artificial neural networks. They both introduce non-
linearity into the model, allowing it to learn complex patterns. Below is a
detailed overview of each function, their characteristics, advantages,
disadvantages, and comparisons.

1. Logistic Sigmoid Function

Definition

The logistic sigmoid function is defined mathematically as:


Characteristics

 Range: The output of the sigmoid function ranges from 0 to 1.


 S-shaped Curve: The function has an S-shaped curve, which makes it useful
for modeling probabilities.
Advantages:
 Produces outputs between 0 and 1, making it suitable for binary classification
tasks.
 Differentiable, allowing for gradient-based optimization.

Disadvantages:

 Can suffer from the vanishing gradient problem when used in deep neural
networks.
The vanishing gradient problem is a phenomenon that occurs in deep
neural networks where the gradients of the error with respect to the
weights in the earlier layers become very small during training. This
can make it difficult for the network to learn effectively, especially for
deep networks with many layers.
 Computationally expensive.
2. Hyperbolic Tangent (tanh) Function

Definition

The hyperbolic tangent function is defined as:

Advantages:

 Produces outputs between -1 and 1, which can be useful for certain


applications.
 Can be more efficient to compute than the sigmoid function.

Disadvantages:

 Can also suffer from the vanishing gradient problem.


Other activation functions:

Linear Hidden Units:


 Hidden units can also be linear, i.e., without any activation function,
though a fully linear network would reduce the model's capacity to
model complex functions.

Softmax Units:
 Typically used in output layers to represent probability distributions.

Radial Basis Function (RBF) Units:


 Activation depends on the distance.

Hard Tanh:

 Similar to tanh and ReLU but bounded between -1 and 1.

Architecture design:

 Architecture: Refers to the network's overall structure, including


the number of units (nodes) and their connections.
 Layers: Neural networks are organized into layers, with each layer
often being a function of the previous layer.
 Chain Structure: Most architectures follow a chain structure where
each layer depends on the one before it.
 Layer Functions: The function of each layer can be expressed as:

Depth and Width:


Depth: The number of layers in the network.
Width: The number of units in each layer.
Network Capacity: Even a single hidden layer can fit the training set, but
deeper networks generally use fewer units per layer and fewer parameters.
Optimization: Deeper networks are more challenging to optimize but may
generalize better to unseen data.
Experimentation: The best architecture is often found through trial and
error, monitored by validation set performance.
1 .Universal Approximation Properties and Depth:
 Linear Models: Linear models can only represent linear functions
and are easy to train, often with convex optimization.
 Nonlinearity Requirement: Learning nonlinear functions
generally requires nonlinear models, which is why neural networks
with hidden layers are useful.

Universal Approximation Theorem:


 Nonlinear Function Approximation: Feedforward neural networks
with at least one hidden layer and a suitable activation function (like
sigmoid or ReLU) can approximate any continuous function to arbitrary
accuracy.
 Depth vs. Width: While deeper networks are often more powerful, a
single hidden layer is theoretically sufficient. However, deeper
networks can learn more complex functions with fewer units.

No Free Lunch Theorem: No single machine learning algorithm can be universally


optimal;

 Network Size: While universal approximation is theoretically possible,


the theorem does not specify the required network size, which can be very
large, sometimes even exponential in worst-case scenarios.
 Practical Limitations: Barron (1993) provided bounds for network size,
but certain functions might still require an impractically large number of
hidden units.
key points about feedforward networks, depth, and
efficiency:
 Single-Layer Networks: While a single hidden layer in a
feedforward network can represent any function, it may require an
impractically large number of units, limiting its ability to generalize
effectively.
 Benefits of Depth: Deeper models often require fewer units and
achieve lower generalization error compared to shallower
networks.
 Depth Efficiency: Some functions can be efficiently approximated
by deep networks.
 Rectified Linear Units (ReLU): Modern results indicate that deep
networks with rectifiers (ReLU) or similar activation functions can
represent functions with exponentially many piecewise linear regions,
enhancing their ability to capture complex patterns.

Fig: The test set accuracy consistently increases with increasing depth.

2 .Other Architectural Considerations


 Diverse Architectures: Neural networks come in various architectures
beyond simple chains.
 Specialized Architectures:
 Convolutional Neural Networks (CNNs): Designed for image and video
processing.
 Recurrent Neural Networks (RNNs): Designed for sequential data like
text and time series.
 Skip Connections: These connections bypass layers, allowing gradients
to flow more easily and improving training.
 Flexibility: Neural network architectures can be customized to suit
specific tasks and data types.
key considerations for connecting layers in neural network
architecture:
 Full Connectivity: The default approach is to connect every input
unit to every output unit.
 Sparse Connectivity: Reducing the number of connections can
improve computational efficiency and prevent overfitting.
CNN uses Sparse connection.

BackPropagation:
 Forward Propagation: The process of input data flowing through the
network to produce an output.
 Backward Propagation: The process of calculating the gradient of the cost
function with respect to the network's parameters.
 Gradient Calculation: Backpropagation efficiently computes the gradient
using a simple procedure.
1 .Computational Graphs:

Definition:
 A computational graph is a formal way to represent
operations in neural networks where each node represents
a variable (e.g., scalar, vector, matrix, tensor).
Operations:
 An operation is a function applied to one or more
variables. Complex functions can be described by
combining multiple simple operations.

The diagram you provided represents a Bayesian network with three


nodes: x, y, and z. The arrows indicate conditional dependencies between
the variables:
 z depends on both x and y
 x and y are independent

2 .Chain Rule of Calculus:


The chain rule is a fundamental mathematical concept that is crucial in the
training of neural networks. It allows us to compute the gradient of a
composite function, which is essential for backpropagation.
The chain rule is used in backpropagation to calculate the gradient
of the error with respect to the weights and biases in each layer.

Here's a simplified example:

Consider a neural network with two hidden layers and an output layer. Let's
denote the output of the first hidden layer as h1, the output of the second
hidden layer as h2, and the final output as y. The error function is denoted as
J(y).

To calculate the gradient of the error with respect to the weights in the first
hidden layer, we can use the chain rule:

dJ/dw1 = dJ/dh2 * dh2/dh1 * dh1/dw1

This equation breaks down the gradient calculation into three parts:

1. dJ/dh2: The gradient of the error with respect to the output of the
second hidden layer.
2. dh2/dh1: The gradient of the output of the second hidden layer with
respect to the output of the first hidden layer.
3. dh1/dw1: The gradient of the output of the first hidden layer with
respect to its weights.
Back propagation Algorithm:
Backpropagation is a supervised learning algorithm used to
train artificial neural networks. It's a method for calculating the
gradient of the error function with respect to the network's
weights and biases, allowing the network to learn from its
mistakes and improve its performance.

How Backpropagation Works:

1. Forward Propagation:
a. Input data is fed into the network's input layer.
b. The data passes through the hidden layers, with each
layer applying an activation function to its weighted
sum of inputs.
c. The final output layer produces a predicted output.
2. Calculate Error:
a. The error between the predicted output and the actual
target is calculated using a loss function (e.g., mean
squared error, cross-entropy).
3. Backward Propagation:
a. The error is propagated backward through the network,
layer by layer.
b. At each layer, the gradient of the error with respect to
the weights and biases is calculated using the chain
rule.
c. These gradients are used to update the weights and
biases using an optimization algorithm like gradient
descent.
4. Repeat: Steps 1-3 are repeated until the network reaches a
desired level of accuracy or a stopping criterion is met.
Example: [Link]

Regularization for Deep Learning:


What are Overfitting?
 Overfitting: A machine learning model is said to be overfitting when it
performs well on the training data but poorly on unseen data.
 Learning Noise: Overfitted models tend to learn the noise or random
fluctuations in the training data, rather than the underlying patterns.
 Memorization: An overfitted model essentially memorizes the training data,
instead of generalizing from it.
Fig :overfitting

What are underfitting?

Underfitting occurs when a model is too simple to capture the underlying patterns
in the data. As a result, it performs poorly on both the training and validation data.

 Poor Performance on Training Data: An underfit model struggles to learn


even from the training data itself.
 Need for Model Complexity: To address underfitting, we need to increase
the complexity of the model, either by adding more layers, increasing the
number of units per layer, or incorporating more features into the data.
We need a smooth curve that should fit well in the training and testing data
[Link] that we are going for Regularization.

Bias refers to the systematic error that occurs when a model is too simple to
capture the underlying patterns in the data. A high-bias model underfits the data,
leading to poor performance both on the training and test sets.

Variance refers to the variability of the model's predictions on different training


sets. A high-variance model is too sensitive to the specific training data and may
perform well on the training set but poorly on unseen data (overfitting).

 High Bias (Underfitting): The left graph shows a simple linear model
that underfits the data. It fails to capture the underlying trend and has a
high bias.
 High Variance (Overfitting): The right graph shows a complex
polynomial model that overfits the data. It captures the noise in the
training data and performs poorly on unseen data.

The goal is to find a balance between bias and variance.

Regularization:

 A technique used to modify a learning algorithm to reduce its generalization


error/test error(i.e overfitting).

 Goal: Regularization aims to reduce test error without necessarily lowering


training error.
 General Concepts: Balances bias-variance trade-off to prevent overfitting.
Regularization adds constraints or penalties to the objective function,
enhancing model performance on unseen data
1. Parameter Norm Penalties:
 Purpose:
 To reduce overfitting by penalizing large weight values, encouraging the
model to favor simpler solutions that generalize better on unseen data.
 Adding a penalty to the objective function constrains the network’s
parameters, discouraging complex or large weights.
Types of Norm Penalties:

a.L1 Regularization /LASSO regression:

 Least Absolute Shrinkage and Selection operator.

 Lasso Regression is a regression model that uses L1 regularization.


 Adds a penalty proportional to the absolute value of the weights.
 Encourages sparsity in the weight matrix by pushing some weights toward
zero.
 Useful for feature selection since some weights can drop to exactly zero,
effectively ignoring certain features.
Example:

Without Regularization:

Imagine we are training a linear regression model with 10 features. Without


regularization:

 All features will have nonzero weights.


 Some weights might be large, leading to overfitting.

With L1 Regularization:

 If 3 of the 10 features are not important, their weights will shrink to exactly
zero.
 The model will only keep the 7 relevant features, making it simpler and more
robust.

b.L2 Regularization (Ridge Decay):

 Adds a penalty term proportional to the square of the weights .


 Encourages weights to be small, making the model smoother and less
sensitive to individual data points.
 Helps improve stability and convergence during training.

How Norm Penalties Work in Training:

 During training, the regularized loss function is minimized

Here, λ (the regularization coefficient) controls the influence of the penalty term.
Higher values of λ increase the impact of the regularization.

Example:

Without Regularization:

 Suppose you are training a linear regression model with 10 features.


 Without regularization, the model may overfit by assigning large weights to
certain features that fit the noise in the training data.

With L2 Regularization:

 The model will still use all 10 features, but their weights will be smaller.
 Irrelevant features will have very small weights but not zero.

During training, the regularized loss function combines the original loss function
(such as cross-entropy or mean squared error) with a penalty term. This penalty
term, defined by a norm constraint (often L1 or L2), acts as a regularizer, limiting
the size of the model parameters. The purpose is to control the model's complexity
and prevent overfitting.

Fig:An illustration of the effect of L2 (or weight decay) regularization on


the value of the optimal w.

The diagram shows how L2 regularization (weight decay) changes the process
of finding the best weights (w1 and w2 ) in a machine learning model.

 The solid ellipses represent the loss function without any regularization.
They show how "good" or "bad" a certain combination of w1 and w2 is for

o The center of the ellipses (w∗w^\astw∗) is where the loss is smallest


the model.

(the best point without regularization).


 The dotted circles represent the penalty added by L2 regularization. This

dotted circles (w=0).


penalty prefers smaller weights, pulling the solution toward the center of the
Applications and Benefits:
 L2 Regularization is common in neural networks for general-purpose
regularization.
 L1 Regularization is often used when feature selection is needed, as it
creates sparse models by driving some weights to zero.
Norm Penalties as Constrained Optimization
It's a technique to limit the complexity of a model by imposing constraints on its
parameters.

Key Idea
A norm penalty (like L1 or L2 regularization) added to the loss function can be
expressed equivalently as an optimization problem with a constraint.
1. Unconstrained Optimization with Norm Penalty:
The regularized loss function is:

Equivalent Constrained Optimization:


This can be rewritten as a constrained optimization problem:

Examples:
Advantages
 Flexibility: Reformulating as constraints gives better control over the model.
 Interpretability: Helps understand the impact of regularization on
optimization.

Limitations
 Computational Complexity: Solving constrained optimization problems can
be more challenging.
 Parameter Tuning: Choosing τ requires careful cross-validation

Constrained Optimization Problem:


 In a constrained optimization problem, we aim to minimize or maximize a function (often
called the objective function) subject to certain constraints. The constraints can be
equality constraints or inequality constraints.

Lagrange Multiplier:

 The Lagrange multiplier, denoted by α, is a technique used to convert a constrained


optimization problem into an unconstrained one. By introducing a Lagrange multiplier
for each constraint, we create a new function called the Lagrangian.

The Lagrangian:

The Lagrangian function combines the original objective function with the constraints multiplied
by their respective Lagrange multipliers. Here, the constraint is that Ω(θ) should be less than
or equal to k. The Lagrangian is then defined as:

L(θ, α; X, y) = J(θ; X, y) + α(Ω(θ) - k)

 J(θ; X, y): The objective function to be minimized.


 Ω(θ): The constraint function.
 α: The Lagrange multiplier.
 k: The upper bound for the constraint.

The Goal:

 The goal is to find the optimal value of θ that minimizes the Lagrangian function. This
involves finding the right balance between minimizing the loss function and satisfying
the constraint on the norm of the parameters.

Relationship Between α and the Norm(Panalty):

When Ω(θ) > k:

 Norm Violation: This means that the current parameter values θ lead to a norm that
exceeds the specified limit k.
 Increasing α: To penalize this violation, the Lagrange multiplier α should be increased.
 Effect of Increased α: A larger α will increase the contribution of the constraint term in
the Lagrangian, making it more costly for the optimization algorithm to choose parameter
values that violate the constraint.

When Ω(θ) < k:

 Norm Within Limits: The current parameter values satisfy the constraint.
 Decreasing α: In this case, a smaller α is sufficient to maintain the constraint.
 Effect of Decreased α: A smaller α reduces the impact of the constraint term, allowing
the optimization algorithm to focus more on minimizing the objective function.

In essence:

 α acts as a tuning parameter that balances the trade-off between minimizing the objective
function and satisfying the constraint.
 By adjusting α, we can control the degree to which the constraint is enforced.

You might also like