Docsity

Activation Functions, Summaries of Machine Learning

Toggle sidebar
bg1
Activation Functions
Role of Activation Functions in Neural Networks
Activation functions introduce non-linearities into neural networks, enabling them to
approximate complex patterns and functions in the data. Without activation functions, neural
networks would behave as linear models, limiting their ability to solve non-linear problems,
which are common in real-world applications. The choice of activation function affects the
training dynamics, convergence speed, and performance of the neural network.
Common Activation Functions in Deep Neural Networks
1. Sigmoid (Logistic) Activation Function
o Formula: 𝜎(𝑥)=

o Range: (0, 1)
o Characteristics: Produces outputs between 0 and 1, useful for binary
classification.
o Advantages:
Useful in binary classification tasks.
Smooth gradient, making optimization easier.
o Limitations:
Vanishing Gradient Problem: Gradients become very small for large
positive or negative values, slowing down training.
Outputs are not zero-centered, causing inefficiencies during
optimization.
2. Tanh (Hyperbolic Tangent) Activation Function
o Formula: 𝑡𝑎𝑛 ℎ(𝑥)=

o Range: (-1, 1)
o Characteristics: Produces outputs between -1 and 1, which centers the data.
o Advantages:
Zero-centered output helps in faster convergence.
Stronger gradient than sigmoid, making it suitable for hidden layers.
o Limitations:
Suffers from the vanishing gradient problem for large positive or
negative inputs.
3. ReLU (Rectified Linear Unit) Activation Function
o Formula: f(x)=max(0,x)
o Range: [0, ∞)
o Characteristics: Outputs zero for negative inputs and scales positively for
positive inputs.
o Advantages:
Efficiently addresses vanishing gradient problem for positive inputs.
Computationally efficient and widely used in deep networks.
o Limitations:
Dying ReLU Problem: Neurons can become inactive if they output
zero for all inputs, causing them to never learn (gradient remains zero).
4. Leaky ReLU
pf3

Partial preview of the text

Download Activation Functions and more Summaries Machine Learning in PDF only on Docsity!

Activation Functions

Role of Activation Functions in Neural Networks

Activation functions introduce non-linearities into neural networks, enabling them to

approximate complex patterns and functions in the data. Without activation functions, neural

networks would behave as linear models, limiting their ability to solve non-linear problems,

which are common in real-world applications. The choice of activation function affects the

training dynamics, convergence speed, and performance of the neural network.

Common Activation Functions in Deep Neural Networks

  1. Sigmoid (Logistic) Activation Function

o Formula: 𝜎(𝑥) =

ଵ

ଵା௘

షೣ

o Range: (0, 1)

o Characteristics: Produces outputs between 0 and 1, useful for binary

classification.

o Advantages:

 Useful in binary classification tasks.

 Smooth gradient, making optimization easier.

o Limitations:

 Vanishing Gradient Problem: Gradients become very small for large

positive or negative values, slowing down training.

 Outputs are not zero-centered, causing inefficiencies during

optimization.

  1. Tanh (Hyperbolic Tangent) Activation Function

o Formula: 𝑡𝑎𝑛 ℎ(𝑥) =

௘

ೣ

ି௘

షೣ

௘

ೣ

ା௘

షೣ

o Range: (-1, 1)

o Characteristics: Produces outputs between -1 and 1, which centers the data.

o Advantages:

 Zero-centered output helps in faster convergence.

 Stronger gradient than sigmoid, making it suitable for hidden layers.

o Limitations:

 Suffers from the vanishing gradient problem for large positive or

negative inputs.

  1. ReLU (Rectified Linear Unit) Activation Function

o Formula: f(x)=max(0,x)

o Range: [0, ∞)

o Characteristics: Outputs zero for negative inputs and scales positively for

positive inputs.

o Advantages:

 Efficiently addresses vanishing gradient problem for positive inputs.

 Computationally efficient and widely used in deep networks.

o Limitations:

 Dying ReLU Problem: Neurons can become inactive if they output

zero for all inputs, causing them to never learn (gradient remains zero).

  1. Leaky ReLU

o Formula: 𝑓(𝑥) = 𝑥; 𝑖𝑓 𝑥 ≥ 0, 𝑜𝑡ℎ𝑒𝑟𝑤𝑖𝑠𝑒 𝑓(𝑥) = 𝛼𝑥 (where α is a small

constant, typically 0.01)

o Range: (-∞, ∞)

o Characteristics: Allows a small, non-zero gradient for negative inputs, unlike

ReLU.

o Advantages:

 Solves the “dying ReLU” problem by allowing a small gradient for

negative inputs.

o Limitations:

 The choice of the parameter α\alphaα is arbitrary and may need tuning.

  1. Softmax Activation Function

o Formula: S𝑜𝑓𝑡𝑚𝑎𝑥

௘

ೣ

೔

∑ ௘

ೣ

ೕ

ೕ

o Range: (0, 1), with outputs summing to 1

o Characteristics: Converts output to a probability distribution, useful for

multi-class classification.

o Advantages:

 Produces interpretable probabilities for each class.

o Limitations:

 Not suitable for hidden layers due to high computational complexity.

Summary: Advantages and Limitations

Activation

Function

Advantages Limitations

Sigmoid

Good for binary outputs, smooth

gradient

Vanishing gradient, not zero-

centered

Tanh Zero-centered, stronger gradient

Vanishing gradient for large

inputs

ReLU Simple, computationally efficient Dying ReLU problem

Leaky ReLU Solves dying ReLU

Requires hyperparameter

tuning

Softmax

Converts to probability, useful for

classification

High computational cost

Applications of Activation Functions

 Sigmoid and Tanh: Often used in shallow neural networks and in final layers for

binary classification.

 ReLU and Variants (Leaky ReLU, PReLU, ELU): Commonly used in deep

convolutional networks and in hidden layers to handle complex patterns.

 Softmax: Used in the final layer of a network for multi-class classification.

Comparison and Choice of Activation Functions

 Shallow Networks: Sigmoid and Tanh are more prevalent but less common in deep

networks due to vanishing gradient issues.