{"id":42,"date":"2026-04-05T17:35:03","date_gmt":"2026-04-05T17:35:03","guid":{"rendered":"https:\/\/gigz.pk\/dl\/?post_type=lesson&#038;p=42"},"modified":"2026-04-05T17:35:35","modified_gmt":"2026-04-05T17:35:35","slug":"activation-functions-relu-sigmoid-tanh","status":"publish","type":"lesson","link":"https:\/\/gigz.pk\/dl\/index.php\/lesson\/activation-functions-relu-sigmoid-tanh\/","title":{"rendered":"Activation Functions (ReLU, Sigmoid, Tanh)"},"content":{"rendered":"\n<p>Activation functions are a key component of neural networks. They introduce non-linearity into the model, allowing it to learn complex patterns and relationships in data. Without activation functions, a neural network would behave like a simple linear model and fail to capture real-world complexities.<\/p>\n\n\n\n<p><strong>Why Activation Functions are Important<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Enable neural networks to learn non-linear patterns<\/li>\n\n\n\n<li>Help models make meaningful predictions<\/li>\n\n\n\n<li>Control how signals pass from one layer to another<\/li>\n\n\n\n<li>Improve model performance and convergence during training<\/li>\n<\/ul>\n\n\n\n<p><strong>1. ReLU (Rectified Linear Unit)<\/strong><br>ReLU is the most commonly used activation function in deep learning.<\/p>\n\n\n\n<p><strong>Formula<\/strong><br>f(x) = max(0, x)<\/p>\n\n\n\n<p><strong>How it Works<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>If the input is positive, it returns the same value<\/li>\n\n\n\n<li>If the input is negative, it returns 0<\/li>\n<\/ul>\n\n\n\n<p><strong>Advantages<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Simple and computationally efficient<\/li>\n\n\n\n<li>Helps reduce vanishing gradient problem<\/li>\n\n\n\n<li>Speeds up training of deep networks<\/li>\n<\/ul>\n\n\n\n<p><strong>Limitations<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Can suffer from \u201cdead neurons\u201d (neurons that stop updating)<\/li>\n<\/ul>\n\n\n\n<p><strong>Example<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">import numpy as npdef relu(x):<br>    return np.maximum(0, x)print(relu(np.array([-2, -1, 0, 1, 2])))<\/pre>\n\n\n\n<p><strong>2. Sigmoid Function<\/strong><br>Sigmoid is widely used for binary classification problems.<\/p>\n\n\n\n<p><strong>Formula<\/strong><br>f(x) = 1 \/ (1 + e^(-x))<\/p>\n\n\n\n<p><strong>How it Works<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Maps input values to a range between 0 and 1<\/li>\n\n\n\n<li>Useful for probabilities and output layers<\/li>\n<\/ul>\n\n\n\n<p><strong>Advantages<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Smooth and differentiable<\/li>\n\n\n\n<li>Suitable for binary outputs<\/li>\n<\/ul>\n\n\n\n<p><strong>Limitations<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Can cause vanishing gradient problem<\/li>\n\n\n\n<li>Slower convergence compared to ReLU<\/li>\n<\/ul>\n\n\n\n<p><strong>Example<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">def sigmoid(x):<br>    return 1 \/ (1 + np.exp(-x))print(sigmoid(np.array([-2, 0, 2])))<\/pre>\n\n\n\n<p><strong>3. Tanh (Hyperbolic Tangent)<\/strong><br>Tanh is similar to sigmoid but outputs values between -1 and 1.<\/p>\n\n\n\n<p><strong>Formula<\/strong><br>f(x) = tanh(x)<\/p>\n\n\n\n<p><strong>How it Works<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Centers data around zero<\/li>\n\n\n\n<li>Useful in hidden layers<\/li>\n<\/ul>\n\n\n\n<p><strong>Advantages<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Zero-centered output<\/li>\n\n\n\n<li>Often performs better than sigmoid in hidden layers<\/li>\n<\/ul>\n\n\n\n<p><strong>Limitations<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Still suffers from vanishing gradient problem<\/li>\n<\/ul>\n\n\n\n<p><strong>Example<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">def tanh(x):<br>    return np.tanh(x)print(tanh(np.array([-2, 0, 2])))<\/pre>\n\n\n\n<p><strong>Comparison of Activation Functions<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>ReLU<\/strong>: Fast, widely used, best for hidden layers<\/li>\n\n\n\n<li><strong>Sigmoid<\/strong>: Outputs probabilities, best for binary classification output<\/li>\n\n\n\n<li><strong>Tanh<\/strong>: Zero-centered, better than sigmoid for hidden layers<\/li>\n<\/ul>\n\n\n\n<p><strong>When to Use Which Function<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Use <strong>ReLU<\/strong> in hidden layers for most deep learning models<\/li>\n\n\n\n<li>Use <strong>Sigmoid<\/strong> in the output layer for binary classification<\/li>\n\n\n\n<li>Use <strong>Tanh<\/strong> when you need zero-centered outputs<\/li>\n<\/ul>\n\n\n\n<p><strong>Applications in Deep Learning<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Image classification and computer vision tasks<\/li>\n\n\n\n<li>Natural language processing models<\/li>\n\n\n\n<li>Speech recognition systems<\/li>\n\n\n\n<li>Neural networks for prediction and classification<\/li>\n<\/ul>\n\n\n\n<p><strong>Lesson Summary<\/strong><br>In this lesson, you learned about activation functions and their role in neural networks. You explored ReLU, Sigmoid, and Tanh functions, their formulas, advantages, limitations, and use cases. Activation functions are essential for enabling neural networks to learn complex patterns and make accurate predictions.<\/p>\n\n\n<div class=\"yoast-breadcrumbs\"><span><span><a href=\"https:\/\/gigz.pk\/dl\/\">Home<\/a><\/span> \u00bb <span class=\"breadcrumb_last\" aria-current=\"page\">Deep Learning Foundations (Beginner) > Neural Networks Basics > Activation Functions (ReLU, Sigmoid, Tanh)<\/span><\/span><\/div>\n\n\n<div class=\"schema-faq wp-block-yoast-faq-block\"><div class=\"schema-faq-section\" id=\"faq-question-1775410452371\"><strong class=\"schema-faq-question\"><\/strong> <p class=\"schema-faq-answer\"><\/p> <\/div> <\/div>\n","protected":false},"menu_order":22,"template":"","class_list":["post-42","lesson","type-lesson","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.6 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Activation Functions (ReLU, Sigmoid, Tanh) - Deep Learning Mastery<\/title>\n<meta name=\"description\" content=\"Learn ReLU, Sigmoid, and Tanh activation functions. Understand their roles, formulas, advantages, and use in deep learning models.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/gigz.pk\/dl\/index.php\/lesson\/activation-functions-relu-sigmoid-tanh\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Activation Functions (ReLU, Sigmoid, Tanh) - Deep Learning Mastery\" \/>\n<meta property=\"og:description\" content=\"Learn ReLU, Sigmoid, and Tanh activation functions. Understand their roles, formulas, advantages, and use in deep learning models.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/gigz.pk\/dl\/index.php\/lesson\/activation-functions-relu-sigmoid-tanh\/\" \/>\n<meta property=\"og:site_name\" content=\"Deep Learning Mastery\" \/>\n<meta property=\"article:modified_time\" content=\"2026-04-05T17:35:35+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":[\"WebPage\",\"FAQPage\"],\"@id\":\"https:\\\/\\\/gigz.pk\\\/dl\\\/index.php\\\/lesson\\\/activation-functions-relu-sigmoid-tanh\\\/\",\"url\":\"https:\\\/\\\/gigz.pk\\\/dl\\\/index.php\\\/lesson\\\/activation-functions-relu-sigmoid-tanh\\\/\",\"name\":\"Activation Functions (ReLU, Sigmoid, Tanh) - Deep Learning Mastery\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/gigz.pk\\\/dl\\\/#website\"},\"datePublished\":\"2026-04-05T17:35:03+00:00\",\"dateModified\":\"2026-04-05T17:35:35+00:00\",\"description\":\"Learn ReLU, Sigmoid, and Tanh activation functions. Understand their roles, formulas, advantages, and use in deep learning models.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/gigz.pk\\\/dl\\\/index.php\\\/lesson\\\/activation-functions-relu-sigmoid-tanh\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/gigz.pk\\\/dl\\\/index.php\\\/lesson\\\/activation-functions-relu-sigmoid-tanh\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/gigz.pk\\\/dl\\\/index.php\\\/lesson\\\/activation-functions-relu-sigmoid-tanh\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/gigz.pk\\\/dl\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Deep Learning Foundations (Beginner) > Neural Networks Basics > Activation Functions (ReLU, Sigmoid, Tanh)\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/gigz.pk\\\/dl\\\/#website\",\"url\":\"https:\\\/\\\/gigz.pk\\\/dl\\\/\",\"name\":\"Deep Learning Mastery\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/gigz.pk\\\/dl\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Activation Functions (ReLU, Sigmoid, Tanh) - Deep Learning Mastery","description":"Learn ReLU, Sigmoid, and Tanh activation functions. Understand their roles, formulas, advantages, and use in deep learning models.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/gigz.pk\/dl\/index.php\/lesson\/activation-functions-relu-sigmoid-tanh\/","og_locale":"en_US","og_type":"article","og_title":"Activation Functions (ReLU, Sigmoid, Tanh) - Deep Learning Mastery","og_description":"Learn ReLU, Sigmoid, and Tanh activation functions. Understand their roles, formulas, advantages, and use in deep learning models.","og_url":"https:\/\/gigz.pk\/dl\/index.php\/lesson\/activation-functions-relu-sigmoid-tanh\/","og_site_name":"Deep Learning Mastery","article_modified_time":"2026-04-05T17:35:35+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":["WebPage","FAQPage"],"@id":"https:\/\/gigz.pk\/dl\/index.php\/lesson\/activation-functions-relu-sigmoid-tanh\/","url":"https:\/\/gigz.pk\/dl\/index.php\/lesson\/activation-functions-relu-sigmoid-tanh\/","name":"Activation Functions (ReLU, Sigmoid, Tanh) - Deep Learning Mastery","isPartOf":{"@id":"https:\/\/gigz.pk\/dl\/#website"},"datePublished":"2026-04-05T17:35:03+00:00","dateModified":"2026-04-05T17:35:35+00:00","description":"Learn ReLU, Sigmoid, and Tanh activation functions. Understand their roles, formulas, advantages, and use in deep learning models.","breadcrumb":{"@id":"https:\/\/gigz.pk\/dl\/index.php\/lesson\/activation-functions-relu-sigmoid-tanh\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/gigz.pk\/dl\/index.php\/lesson\/activation-functions-relu-sigmoid-tanh\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/gigz.pk\/dl\/index.php\/lesson\/activation-functions-relu-sigmoid-tanh\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/gigz.pk\/dl\/"},{"@type":"ListItem","position":2,"name":"Deep Learning Foundations (Beginner) > Neural Networks Basics > Activation Functions (ReLU, Sigmoid, Tanh)"}]},{"@type":"WebSite","@id":"https:\/\/gigz.pk\/dl\/#website","url":"https:\/\/gigz.pk\/dl\/","name":"Deep Learning Mastery","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/gigz.pk\/dl\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/gigz.pk\/dl\/index.php\/wp-json\/wp\/v2\/lesson\/42","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gigz.pk\/dl\/index.php\/wp-json\/wp\/v2\/lesson"}],"about":[{"href":"https:\/\/gigz.pk\/dl\/index.php\/wp-json\/wp\/v2\/types\/lesson"}],"wp:attachment":[{"href":"https:\/\/gigz.pk\/dl\/index.php\/wp-json\/wp\/v2\/media?parent=42"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}