diff --git a/SUBMISSION/NaveenPaudel.md b/SUBMISSION/NaveenPaudel.md new file mode 100644 index 0000000..e2075f7 --- /dev/null +++ b/SUBMISSION/NaveenPaudel.md @@ -0,0 +1,2 @@ +# Name: Naveen Paudel +## Enrollment number: 19608441P diff --git a/annpractisepart3.ipynb b/annpractisepart3.ipynb new file mode 100644 index 0000000..8c6595a --- /dev/null +++ b/annpractisepart3.ipynb @@ -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": [ + "\"Open" + ] + }, + { + "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" + ] + } + ] + } + ] +} \ No newline at end of file