×
1 Choose EITC/EITCA Certificates
2 Learn and take online exams
3 Get your IT skills certified

Confirm your IT skills and competencies under the European IT Certification framework from anywhere in the world fully online.

EITCA Academy

Digital skills attestation standard by the European IT Certification Institute aiming to support Digital Society development

LOG IN TO YOUR ACCOUNT

CREATE AN ACCOUNT FORGOT YOUR PASSWORD?

FORGOT YOUR PASSWORD?

AAH, WAIT, I REMEMBER NOW!

CREATE AN ACCOUNT

ALREADY HAVE AN ACCOUNT?
EUROPEAN INFORMATION TECHNOLOGIES CERTIFICATION ACADEMY - ATTESTING YOUR PROFESSIONAL DIGITAL SKILLS
  • SIGN UP
  • LOGIN
  • INFO

EITCA Academy

EITCA Academy

The European Information Technologies Certification Institute - EITCI ASBL

Certification Provider

EITCI Institute ASBL

Brussels, European Union

Governing European IT Certification (EITC) framework in support of the IT professionalism and Digital Society

  • CERTIFICATES
    • EITCA ACADEMIES
      • EITCA ACADEMIES CATALOGUE<
      • EITCA/CG COMPUTER GRAPHICS
      • EITCA/IS INFORMATION SECURITY
      • EITCA/BI BUSINESS INFORMATION
      • EITCA/KC KEY COMPETENCIES
      • EITCA/EG E-GOVERNMENT
      • EITCA/WD WEB DEVELOPMENT
      • EITCA/AI ARTIFICIAL INTELLIGENCE
    • EITC CERTIFICATES
      • EITC CERTIFICATES CATALOGUE<
      • COMPUTER GRAPHICS CERTIFICATES
      • WEB DESIGN CERTIFICATES
      • 3D DESIGN CERTIFICATES
      • OFFICE IT CERTIFICATES
      • BITCOIN BLOCKCHAIN CERTIFICATE
      • WORDPRESS CERTIFICATE
      • CLOUD PLATFORM CERTIFICATENEW
    • EITC CERTIFICATES
      • INTERNET CERTIFICATES
      • CRYPTOGRAPHY CERTIFICATES
      • BUSINESS IT CERTIFICATES
      • TELEWORK CERTIFICATES
      • PROGRAMMING CERTIFICATES
      • DIGITAL PORTRAIT CERTIFICATE
      • WEB DEVELOPMENT CERTIFICATES
      • DEEP LEARNING CERTIFICATESNEW
    • CERTIFICATES FOR
      • EU PUBLIC ADMINISTRATION
      • TEACHERS AND EDUCATORS
      • IT SECURITY PROFESSIONALS
      • GRAPHICS DESIGNERS & ARTISTS
      • BUSINESSMEN AND MANAGERS
      • BLOCKCHAIN DEVELOPERS
      • WEB DEVELOPERS
      • CLOUD AI EXPERTSNEW
  • FEATURED
  • SUBSIDY
  • HOW IT WORKS
  •   IT ID
  • ABOUT
  • CONTACT
  • MY ORDER
    Your current order is empty.
EITCIINSTITUTE
CERTIFIED

What is the formula for an activation function such as Rectified Linear Unit to introduce non-linearity into the model?

by EITCA Academy / Thursday, 23 May 2024 / Published in Artificial Intelligence, EITC/AI/ADL Advanced Deep Learning, Advanced computer vision, Convolutional neural networks for image recognition

The Rectified Linear Unit (ReLU) is one of the most commonly used activation functions in deep learning, particularly within convolutional neural networks (CNNs) for image recognition tasks. The primary purpose of an activation function is to introduce non-linearity into the model, which is essential for the network to learn from the data and perform complex tasks.

The mathematical formula for the ReLU activation function is defined as:

[ f(x) = max(0, x) ]

Where:
– ( f(x) ) is the output of the activation function.
– ( x ) is the input to the activation function.

The ReLU function outputs the input directly if it is positive; otherwise, it outputs zero. This can be expressed more formally as:

[
f(x) = begin{cases}
x & text{if } x > 0 \
0 & text{if } x leq 0
end{cases}
]

This piecewise linear function is computationally efficient, which makes it particularly well-suited for deep learning models that require the processing of large datasets and complex computations.

Advantages of ReLU

1. Simplicity and Computational Efficiency: The ReLU function is simple to implement and compute. Unlike other activation functions such as the sigmoid or hyperbolic tangent (tanh), which involve exponential calculations, ReLU only requires a thresholding at zero. This simplicity translates to faster computations and improved training times.

2. Sparse Activation: ReLU can lead to sparse activation. Sparse activation means that for a given input, only a certain number of neurons are activated (i.e., have non-zero output). This sparsity can make the network more efficient and less prone to overfitting, as fewer neurons are involved in computation at any given time.

3. Mitigation of the Vanishing Gradient Problem: In deep networks, gradients can become very small during backpropagation, making it difficult for the network to learn. This issue is known as the vanishing gradient problem. ReLU helps mitigate this problem by maintaining gradients that are either zero or one, ensuring that gradients do not diminish as they propagate through the network.

Disadvantages of ReLU

1. Dying ReLU Problem: One of the primary drawbacks of ReLU is the "dying ReLU" problem. During training, some neurons can get stuck in a state where they output zero for any input. This can happen if a large gradient flows through a ReLU neuron, causing the weights to update in such a way that the neuron will always output zero. Once a neuron is stuck in this state, it will no longer contribute to the learning process, effectively "dying."

2. Unbounded Output: The output of the ReLU function is unbounded for positive inputs. This can sometimes lead to issues with exploding gradients, where the gradients become excessively large, causing instability in the training process.

Variants of ReLU

To address some of the limitations of the standard ReLU, several variants have been proposed:

1. Leaky ReLU: Leaky ReLU introduces a small slope for negative inputs, allowing a small, non-zero gradient when the input is less than zero. The formula for Leaky ReLU is:

[
f(x) = begin{cases}
x & text{if } x > 0 \
alpha x & text{if } x leq 0
end{cases}
]

where ( alpha ) is a small constant, typically ( alpha = 0.01 ). This modification helps mitigate the dying ReLU problem by ensuring that neurons can still learn even when they receive negative inputs.

2. Parametric ReLU (PReLU): PReLU is an extension of Leaky ReLU where the slope for negative inputs is learned during training. The formula for PReLU is:

[
f(x) = begin{cases}
x & text{if } x > 0 \
alpha x & text{if } x leq 0
end{cases}
]

In PReLU, ( alpha ) is not a fixed constant but a parameter that is learned during the training process. This allows the model to adapt the activation function to the specific characteristics of the data.

3. Exponential Linear Unit (ELU): ELU introduces an exponential component for negative inputs, which can help to bring the mean activation closer to zero and reduce the bias shift. The formula for ELU is:

[
f(x) = begin{cases}
x & text{if } x > 0 \
alpha (e^x – 1) & text{if } x leq 0
end{cases}
]

where ( alpha ) is a positive constant. ELU can improve learning speed and performance by ensuring that the mean activation is closer to zero.

Application in Convolutional Neural Networks

In the context of convolutional neural networks (CNNs) for image recognition, ReLU and its variants play a important role in enabling the network to learn complex patterns and features from the input images. CNNs consist of multiple layers, including convolutional layers, pooling layers, and fully connected layers. The convolutional layers apply filters to the input images to detect features such as edges, textures, and shapes. The activation function is applied after each convolutional layer to introduce non-linearity and allow the network to learn more complex representations.

For example, consider a simple CNN architecture for image recognition:

1. Convolutional Layer 1: Applies a set of filters to the input image to detect low-level features such as edges.
2. ReLU Activation: Applies the ReLU activation function to the output of the convolutional layer, introducing non-linearity.
3. Pooling Layer 1: Reduces the spatial dimensions of the feature maps, retaining the most important information.
4. Convolutional Layer 2: Applies another set of filters to the pooled feature maps to detect higher-level features.
5. ReLU Activation: Applies the ReLU activation function to the output of the second convolutional layer.
6. Pooling Layer 2: Further reduces the spatial dimensions of the feature maps.
7. Fully Connected Layer: Flattens the feature maps and connects them to a set of neurons, enabling the network to make predictions.
8. Softmax Activation: Applies the softmax activation function to the output of the fully connected layer to obtain the final class probabilities.

In this architecture, the ReLU activation function is applied after each convolutional layer to introduce non-linearity and enable the network to learn from the data. The softmax activation function is applied at the end of the network to obtain the final class probabilities for image recognition.

Example

To illustrate the use of ReLU in a CNN, consider the following example in Python using the Keras library:

python
from keras.models import Sequential
from keras.layers import Conv2D, MaxPooling2D, Flatten, Dense, Activation

# Define the CNN model
model = Sequential()

# Add the first convolutional layer
model.add(Conv2D(32, (3, 3), input_shape=(64, 64, 3)))
# Apply the ReLU activation function
model.add(Activation('relu'))

# Add the first pooling layer
model.add(MaxPooling2D(pool_size=(2, 2)))

# Add the second convolutional layer
model.add(Conv2D(64, (3, 3)))
# Apply the ReLU activation function
model.add(Activation('relu'))

# Add the second pooling layer
model.add(MaxPooling2D(pool_size=(2, 2)))

# Flatten the feature maps
model.add(Flatten())

# Add the fully connected layer
model.add(Dense(128))
# Apply the ReLU activation function
model.add(Activation('relu'))

# Add the output layer with softmax activation
model.add(Dense(10))
model.add(Activation('softmax'))

# Compile the model
model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['accuracy'])

# Print the model summary
model.summary()

In this example, the ReLU activation function is applied after each convolutional and fully connected layer to introduce non-linearity and enable the network to learn from the data. The softmax activation function is applied at the end of the network to obtain the final class probabilities for image recognition.

Conclusion

The Rectified Linear Unit (ReLU) activation function is a fundamental component of deep learning models, particularly convolutional neural networks (CNNs) for image recognition tasks. Its simplicity, computational efficiency, and ability to mitigate the vanishing gradient problem make it a popular choice among researchers and practitioners. However, it is important to be aware of its limitations, such as the dying ReLU problem, and consider using variants like Leaky ReLU, PReLU, or ELU when appropriate. By understanding the role of ReLU and its variants in CNNs, one can design and train more effective and efficient deep learning models for image recognition and other complex tasks.

Other recent questions and answers regarding Convolutional neural networks for image recognition:

  • What is the mathematical formula for the loss function in convolution neural networks?
  • What is the mathematical formula of the convolution operation on a 2D image?
  • What is the equation for the max pooling?
  • How do residual connections in ResNet architectures facilitate the training of very deep neural networks, and what impact did this have on the performance of image recognition models?
  • What were the major innovations introduced by AlexNet in 2012 that significantly advanced the field of convolutional neural networks and image recognition?
  • How do pooling layers, such as max pooling, help in reducing the spatial dimensions of feature maps and controlling overfitting in convolutional neural networks?
  • What are the key differences between traditional fully connected layers and locally connected layers in the context of image recognition, and why are locally connected layers more efficient for this task?
  • How does the concept of weight sharing in convolutional neural networks (ConvNets) contribute to translation invariance and reduce the number of parameters in image recognition tasks?
  • What were Convolutional Neural Networks first designed for?

More questions and answers:

  • Field: Artificial Intelligence
  • Programme: EITC/AI/ADL Advanced Deep Learning (go to the certification programme)
  • Lesson: Advanced computer vision (go to related lesson)
  • Topic: Convolutional neural networks for image recognition (go to related topic)
Tagged under: Activation Function, Artificial Intelligence, CNN, Deep Learning, Image Recognition, ReLU
Home » Artificial Intelligence » EITC/AI/ADL Advanced Deep Learning » Advanced computer vision » Convolutional neural networks for image recognition » » What is the formula for an activation function such as Rectified Linear Unit to introduce non-linearity into the model?

Certification Center

USER MENU

  • My Account

CERTIFICATE CATEGORY

  • EITC Certification (117)
  • EITCA Certification (9)

What are you looking for?

  • Introduction
  • How it works?
  • EITCA Academies
  • EITCI DSJC Subsidy
  • Full EITC catalogue
  • Your order
  • Featured
  •   IT ID
  • EITCA reviews (Medium publ.)
  • About
  • Contact

EITCA Academy is a part of the European IT Certification framework

The European IT Certification framework has been established in 2008 as a Europe based and vendor independent standard in widely accessible online certification of digital skills and competencies in many areas of professional digital specializations. The EITC framework is governed by the European IT Certification Institute (EITCI), a non-profit certification authority supporting information society growth and bridging the digital skills gap in the EU.
Eligibility for EITCA Academy 90% EITCI DSJC Subsidy support
90% of EITCA Academy fees subsidized in enrolment

    EITCA Academy Secretary Office

    European IT Certification Institute ASBL
    Brussels, Belgium, European Union

    EITC / EITCA Certification Framework Operator
    Governing European IT Certification Standard
    Access contact form or call +32 25887351

    Follow EITCI on X
    Visit EITCA Academy on Facebook
    Engage with EITCA Academy on LinkedIn
    Check out EITCI and EITCA videos on YouTube

    Funded by the European Union

    Funded by the European Regional Development Fund (ERDF) and the European Social Fund (ESF) in series of projects since 2007, currently governed by the European IT Certification Institute (EITCI) since 2008

    Information Security Policy | DSRRM and GDPR Policy | Data Protection Policy | Record of Processing Activities | HSE Policy | Anti-Corruption Policy | Modern Slavery Policy

    Automatically translate to your language

    Terms and Conditions | Privacy Policy
    EITCA Academy
    • EITCA Academy on social media
    EITCA Academy


    © 2008-2026  European IT Certification Institute
    Brussels, Belgium, European Union

    TOP

    We care about your privacy

    EITCI uses cookies and similar technologies to keep this site secure, remember your choices, provide personalized experience, measure the traffic, serve more relevant content and certification programmes. You can accept all cookies or customize your preferences. Cookies are variables used to store website specific information on your device to facilitate processing of data for personalized website visit, such as login to your account, accessing the programmes, placing enrolment orders in chosen programmes and improving your EITC certification journey. You can change or withdraw your consent at any time by clicking the Consent Preferences button at the left-bottom of your screen. We respect your choices and are committed to providing you with a transparent and secure browsing experience, which may be limited when cookies aren't accepted. For more details refer to the Privacy Policy
    Customize Consent Preferences
    We use cookies to help you navigate efficiently and perform certain functions. You will find detailed information about all cookies under each consent category below.
    The cookies categorized as Necessary are stored on your browser as they are essential for enabling the basic functionalities of the site.
    To learn more about how Google processes personal information, visit: Google privacy policy

    Necessary

    Always Active

    Necessary cookies are required to enable the basic features of this site, such as providing secure log-in or adjusting your consent preferences. These cookies do not store any personally identifiable data.

    Functional

    Functional cookies help perform certain functionalities like sharing the content of the website on social media platforms, collecting feedback, and other third-party features.

    Preferences

    Stores personalization choices such as interface preferences.

    External media and social features

    Allows embedded video, social, chat, and external interactive services that may set their own cookies. Keep off until the user chooses these features.

    Analytics

    Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.

    Marketing and conversions

    Advertisement cookies are used to provide visitors with customized advertisements based on the pages you visited previously and to analyze the effectiveness of the ad campaigns.

    CHAT WITH SUPPORT
    Do you have any questions?
    Attach files with the paperclip or paste screenshots into the message box (Ctrl+V). Max 5 file(s), 10 MB each.
    We will reply here and by email. Your conversation is tracked with a support token.