Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hacktoberfest 2021 #17

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions SUBMISSION/NaveenPaudel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Name: Naveen Paudel
## Enrollment number: 19608441P
185 changes: 185 additions & 0 deletions annpractisepart3.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"provenance": [],
"authorship_tag": "ABX9TyPDycAexK6flJEfam5CEsKV",
"include_colab_link": true
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"language_info": {
"name": "python"
}
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/github/NipoTechCRATManiac/Hacktoberfest-2021/blob/main/annpractisepart3.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "markdown",
"source": [
"1.Creating Neural Network with Activation Functions\n"
],
"metadata": {
"id": "XzP77dCNMqoC"
}
},
{
"cell_type": "code",
"source": [
"#Creating Input Layer\n",
"import numpy as np\n",
"data = [5,9]\n",
"x0 = data[0]\n",
"x1 = data[1]\n",
"input_layer = np.array([x0,x1])\n",
"print(\"Input Layer \",input_layer)"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "AQclHTWqMwUa",
"outputId": "a9911719-19e8-4254-cbc3-051c09ccd125"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Input Layer [5 9]\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"#Activation Function - Relu\n",
"def relu(x):\n",
" return (max(0,x))"
],
"metadata": {
"id": "ixawUto9Ry2h"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"#Activation Function - Sigmoid\n",
"def sig(x):\n",
" if x<=0:\n",
" return 0\n",
" else:\n",
" return 1"
],
"metadata": {
"id": "fA76NFojSASK"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"#Creating Hidden Layer1\n",
"weights = {'x2':np.array([1, 3]), 'x3':np.array([3,4])}\n",
"x2 = (input_layer*weights['x2']).sum()\n",
"x3 = (input_layer*weights['x3']).sum()\n",
"x2 = relu(x2)\n",
"x3 = relu(x3)\n",
"hidden_layer1 = np.array([x2,x3])\n",
"print(\"Hidden Layer \",hidden_layer1)"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "_voCW704Nius",
"outputId": "fd57b55b-976b-43a2-de04-54b7c330b69e"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Hidden Layer [32 51]\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"#Creating Hidden Layer2\n",
"weights = {'x4':np.array([-1, 2]), 'x5':np.array([-2,1])}\n",
"x4 = (hidden_layer1*weights['x4']).sum()\n",
"x5 = (hidden_layer1*weights['x5']).sum()\n",
"x4 = relu(x4)\n",
"x5 = relu(x5)\n",
"hidden_layer2 = np.array([x4,x5])\n",
"print(\"Hidden Layer \",hidden_layer2)"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "NvY0nQ0eTEzn",
"outputId": "26938712-0d9e-4798-84c3-c985eeb0e52e"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Hidden Layer [70 0]\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"#Creating Output Layer\n",
"weights = {'x6':np.array([1,-1])}\n",
"x6 = (hidden_layer2*weights['x6']).sum()\n",
"x6 = sig(x6)\n",
"output_layer = np.array([x6])\n",
"print(\"Output Layer \",output_layer)"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "3WsNw790To4a",
"outputId": "58643160-f4da-4d72-e693-f7819580c82b"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Output Layer [1]\n"
]
}
]
}
]
}