fjcamillo / Neural-Representation-of-Logic-Functions

Creating Logic Functions [AND, OR, NOT, XNOR, XOR, NAND, etc] using Neural Network

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Representing Logic Gates using a Neural Network

How to use

In the example below we've created a simple Logic And using our class

>>> from neurallogic import Neural
>>> bias = -0.2
>>> weights = [-0.1 , 0.2, 0.2]
>>> import numpy as np
>>> dataset = np.array([
...     [1,0,0],
...     [1,0,1],
...     [1,1,0],
...     [1,1,1]
... ])
>>> neural = Neural(weights, bias, dataset)
>>> neural.logit
array([[0.42555748],
       [0.47502081],
       [0.47502081],
       [0.52497919]])
>>> neural.__converted__()
array([[0.],
       [0.],
       [0.],
       [1.]])

Here's another example in creating a simple Logic Or using our class

>>> from neurallogic import Neural
>>> import numpy as np
>>> bias = -0.1
>>> weights = [-0.1, 0.7,0.7]
>>> dataset = np.array([
...     [1,0,0],
...     [1,0,1],
...     [1,1,0],
...     [1,1,1]
... ])
>>> neural = Neural(weights, bias, dataset)
>>> neural.logit
array([[0.450166  ],
       [0.62245933],
       [0.62245933],
       [0.76852478]])
>>> neural.__converted__()
array([[0.],
       [1.],
       [1.],
       [1.]])
>>> 

About

Creating Logic Functions [AND, OR, NOT, XNOR, XOR, NAND, etc] using Neural Network


Languages

Language:Python 100.0%