{"id":15065013,"url":"https://github.com/arif-miad/activation-function","last_synced_at":"2026-01-03T11:15:57.984Z","repository":{"id":256100666,"uuid":"854324845","full_name":"Arif-miad/activation-function","owner":"Arif-miad","description":null,"archived":false,"fork":false,"pushed_at":"2024-09-09T00:54:41.000Z","size":177,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-22T11:39:37.507Z","etag":null,"topics":["artificial-intelligence","convolutional-neural-networks","data-science","deep-neural-networks","keras"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Arif-miad.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-09T00:42:09.000Z","updated_at":"2024-09-09T20:50:57.000Z","dependencies_parsed_at":"2024-09-09T01:52:47.260Z","dependency_job_id":"d58d851f-657c-4954-b6f3-7fef3dd8d015","html_url":"https://github.com/Arif-miad/activation-function","commit_stats":null,"previous_names":["arif-miad/activation-function"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Arif-miad%2Factivation-function","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Arif-miad%2Factivation-function/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Arif-miad%2Factivation-function/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Arif-miad%2Factivation-function/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Arif-miad","download_url":"https://codeload.github.com/Arif-miad/activation-function/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243801610,"owners_count":20350106,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["artificial-intelligence","convolutional-neural-networks","data-science","deep-neural-networks","keras"],"created_at":"2024-09-25T00:29:31.444Z","updated_at":"2026-01-03T11:15:57.944Z","avatar_url":"https://github.com/Arif-miad.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\u003cdiv align=\"center\"\u003e\n      \u003cH1\u003e important of activation function\u003c/H1\u003e\n\u003cH2\u003eA In most deep learning frameworks like TensorFlow or PyTorch, you can import activation functions directly from the libraries they provide. Below are examples of how to import and use common activation functions in both frameworks.\n\u003c/H2\u003e  \n     \u003c/div\u003e\n\n\u003cbody\u003e\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"mailto:arifmiahcse952@gmail.com\"\u003e\u003cimg src=\"https://img.shields.io/badge/Email-arifmiah%40gmail.com-blue?style=flat-square\u0026logo=gmail\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/Arif-miad\"\u003e\u003cimg src=\"https://img.shields.io/badge/GitHub-%40ArifMiah-lightgrey?style=flat-square\u0026logo=github\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://www.linkedin.com/in/arif-miah-8751bb217/\"\u003e\u003cimg src=\"https://img.shields.io/badge/LinkedIn-Arif%20Miah-blue?style=flat-square\u0026logo=linkedin\"\u003e\u003c/a\u003e\n\n \n  \n  \u003cbr\u003e\n  \u003cimg src=\"https://img.shields.io/badge/Phone-%2B8801998246254-green?style=flat-square\u0026logo=whatsapp\"\u003e\n  \n\u003c/p\u003e\n1. TensorFlow / Keras:\nKeras, which is part of TensorFlow, has a variety of activation functions built in. You can import them from tensorflow.keras.layers or tensorflow.keras.activations.\n\nExample Imports for Activation Functions in TensorFlow/Keras:\n```python\n# Importing individual activation functions\nfrom tensorflow.keras.layers import Activation\nfrom tensorflow.keras.activations import relu, softmax, sigmoid\n\n# Example usage in a model\nfrom tensorflow.keras.models import Sequential\nfrom tensorflow.keras.layers import Dense\n\n# Build a simple feed-forward neural network model\nmodel = Sequential([\n    Dense(64, input_shape=(784,)),\n    Activation('relu'),  # Using activation by name\n    Dense(10),\n    Activation('softmax')  # Using activation by name\n])\n\n# Alternatively, you can use activation functions directly in Dense layers\nmodel = Sequential([\n    Dense(64, activation=relu, input_shape=(784,)),  # Using relu\n    Dense(10, activation=softmax)  # Using softmax\n])\n\n```\n2. PyTorch:\nIn PyTorch, activation functions are available in torch.nn (as layers) or torch.nn.functional (as functions).\n\nExample Imports for Activation Functions in PyTorch:\n\n```python\n# Importing activation functions from torch.nn.functional\nimport torch.nn.functional as F\n\n# Example usage in a custom neural network model\nimport torch\nimport torch.nn as nn\n\nclass SimpleModel(nn.Module):\n    def __init__(self):\n        super(SimpleModel, self).__init__()\n        self.fc1 = nn.Linear(784, 64)\n        self.fc2 = nn.Linear(64, 10)\n    \n    def forward(self, x):\n        x = F.relu(self.fc1(x))  # Using relu activation\n        x = F.softmax(self.fc2(x), dim=1)  # Using softmax activation\n        return x\n\n# Creating an instance of the model\nmodel = SimpleModel()\n\n```\nCommonly Used Activation Functions in PyTorch:\nReLU: F.relu(x) or nn.ReLU()\nSigmoid: F.sigmoid(x) or nn.Sigmoid()\nSoftmax: F.softmax(x, dim=1) or nn.Softmax(dim=1)\nTanh: F.tanh(x) or nn.Tanh()\nThese activations can be used either as part of layers or as standalone functions during the forward pass, depending on how you prefer to structure the model.\n```python\n# Linear Activation Functions\nimport numpy as np \nimport matplotlib.pyplot as plt\n\n# Define the linear activation fucntion\ndef linear_activation(x):\n    return x \n# Generate a range of values\nx = np.linspace(-10,10,400) \ny = linear_activation(x)\nplt.figure(figsize=(4,3))\nplt.plot(x,y,label=\"Linear Activation\", color=\"blue\")\nplt.title(\"Linear Activation Function\")\nplt.xlabel(\"INput\")\nplt.ylabel(\"Output\")\nplt.grid(True)\nplt.legend()\nplt.show()\n\n```\n```python\n# Sinmoid Activation Function\ndef sigmoid(x):\n    return 1/(1+np.exp(-x))\nx = np.linspace(-10,10,600)\ny = sigmoid(x)\nplt.plot(x,y)\nplt.title(\"sigmoid Activation function\")\nplt.xlabel(\"Input\")\nplt.ylabel(\"Output\")\nplt.grid(True)\nplt.show()\n```\n\n```python\ndef tanh_function(x):\n    return np.tanh(x)\nx = np.linspace(-20,20,500)\ny = tanh_function(x)\nplt.figure(figsize=(8,6))\nplt.plot(x,y,label='tanh(x)', color='blue')\nplt.title(\"Hyperblic Tangent Function (tanh)\")\nplt.xlabel('x')\nplt.ylabel('tanh(x)')\nplt.grid(True, which='both', linestyle='--', linewidth=0.5)\n```\n```python\ndef relu(x):\n    return np.maximum(0,x)\nx = np.linspace(-30,30,800)\ny = relu(x)\nplt.figure(figsize=(10,5))\nplt.plot(x,y, label='ELU function', color='blue')\nplt.title('ReLU Activation Function')\nplt.xlabel('x')\nplt.ylabel(\"ReLU(x)\")\nplt.grid()\n    \nplt.legend()\nplt.show()\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farif-miad%2Factivation-function","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farif-miad%2Factivation-function","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farif-miad%2Factivation-function/lists"}