Oct-09-2018, 04:39 PM
I've recently got interested in Neural Networks, and I wanted to try and create one using Python. I am not very advanced with Python, I just know the basic stuff. I also don't think I have totally understood all about Neural Networks.
What i created is what I understood about the topic from online sources, especially this one: https://becominghuman.ai/making-a-simple...a1de81ec20
I've read about the NN learning with trials in the above article, and wanted to try and recreate it.
The structure I chose is super simple: 2 "input neurons" (one of them has the value of 1 and the other has the value of 0), 2 neurons in one hidden layer, and one output.
Simple representation:
input neuron1 --- layer neuron1 - - output1
input neuron2 --- layer neuron2 - - output1
My only question is: is this considered a learning Neural Network or is it just a 'simulation' of it?
In the code the values of the input neurons is chosen pseudorandomly.
The way it learns is that each time that it sees which input neuron is active, the weight that neuron has is increased by 0.2, and the next neuron has a threshold of 1 (so when the weight reaches 1, the next neuron activates and then generates the output).
It's simpler to understand if you read a part of the article I linked.
Here is the code:
Thank you!
What i created is what I understood about the topic from online sources, especially this one: https://becominghuman.ai/making-a-simple...a1de81ec20
I've read about the NN learning with trials in the above article, and wanted to try and recreate it.
The structure I chose is super simple: 2 "input neurons" (one of them has the value of 1 and the other has the value of 0), 2 neurons in one hidden layer, and one output.
Simple representation:
input neuron1 --- layer neuron1 - - output1
input neuron2 --- layer neuron2 - - output1
My only question is: is this considered a learning Neural Network or is it just a 'simulation' of it?
In the code the values of the input neurons is chosen pseudorandomly.
The way it learns is that each time that it sees which input neuron is active, the weight that neuron has is increased by 0.2, and the next neuron has a threshold of 1 (so when the weight reaches 1, the next neuron activates and then generates the output).
It's simpler to understand if you read a part of the article I linked.
Here is the code:
import random randX = random.randint(0,1) if randX == 0: randY = 1 elif randX == 1: randY = 0 class inpNeur: def __init__(self,value): self.val = value self.w = self.val*0 class layNeur: def __init__(self,w): global thresh thresh = 1 self.val = w self.w = self.val class output: def __init__(self,w): self.val = w in1 = inpNeur(randX) in2 = inpNeur(randY) n1 = layNeur(in1.w) n2 = layNeur(in2.w) out = output(n1.val+n2.val) inpL = [in1,in2] def trial(): for x in inpL: x.w += .2*x.val global n1 global n2 n1 = layNeur(in1.w) n2 = layNeur(in2.w) if n1.val+n2.val < thresh: pass else: global out out = output(n1.val+n2.val) if out.val > 0: print(f'OUTPUT = {out.val}')Does anybody know if I actually created a simple learning Neural Network?
Thank you!