Simple Implementation of a Neural Network
Python3
import numpy as np # array of any amount of numbers. n = m X = np.array([[ 1 , 2 , 3 ], [ 3 , 4 , 1 ], [ 2 , 5 , 3 ]]) # multiplication y = np.array([[. 5 , . 3 , . 2 ]]) # transpose of y y = y.T # sigma value sigm = 2 # find the delta delt = np.random.random(( 3 , 3 )) - 1 for j in range ( 100 ): # find matrix 1. 100 layers. m1 = (y - ( 1 / ( 1 + np.exp( - (np.dot(( 1 / ( 1 + np.exp( - (np.dot(X, sigm))))), delt)))))) * (( 1 / ( 1 + np.exp( - (np.dot(( 1 / ( 1 + np.exp( - (np.dot(X, sigm))))), delt))))) * ( 1 - ( 1 / ( 1 + np.exp( - (np.dot(( 1 / ( 1 + np.exp( - (np.dot(X, sigm))))), delt))))))) # find matrix 2 m2 = m1.dot(delt.T) * (( 1 / ( 1 + np.exp( - (np.dot(X, sigm))))) * ( 1 - ( 1 / ( 1 + np.exp( - (np.dot(X, sigm))))))) # find delta delt = delt + ( 1 / ( 1 + np.exp( - (np.dot(X, sigm))))).T.dot(m1) # find sigma sigm = sigm + (X.T.dot(m2)) # print output from the matrix print ( 1 / ( 1 + np.exp( - (np.dot(X, sigm))))) |
Output:
[[0.99999325 0.99999375 0.99999352]
[0.99999988 0.99999989 0.99999988]
[1. 1. 1. ]]
What is a neural network?
Neural Networks are computational models that mimic the complex functions of the human brain. The neural networks consist of interconnected nodes or neurons that process and learn from data, enabling tasks such as pattern recognition and decision making in machine learning. The article explores more about neural networks, their working, architecture and more.
Table of Content
- Evolution of Neural Networks
- What are Neural Networks?
- How does Neural Networks work?
- Learning of a Neural Network
- Types of Neural Networks
- Simple Implementation of a Neural Network