Beginner @ coding / First "AI" project


#1

Hello everyone!
I am a beginner programmer and have been trying to learn python on my own for a few months now and decided it was time to reach out to the python community for help and resources.
i have an AI project I’ve been working on and would love to get some feedback on it.

‘’’ Basic feedforward neural network based on the following youtube link https://www.youtube.com/watch?v=ILsA4nyG7I0
does not include a function for updating weights.
any constructive critique is much appreciated (i’m still new at coding)
comments/questions pythonguy63@protonmail.com

P.S program still has bugs.

Input map is in order of > 1 2
3 4

Black = -1
White = 1
‘’’

input 4 pixel map

n1 = 1
n2 = -1
n3 = -1
n4 = 1

#layer 1 weights
wegt1 = 1
wegt2 = 1
wegt3 = 1
wegt4 = 1
wegt5 = 1
wegt6 = -1
wegt7 = 1
wegt8 = -1

#layer 1 neurons
neuron1 = (n1 * wegt1) + (n4 * wegt2)
#ReLU function {I think}
if neuron1 > 0.1:
neu1 = neuron1
else:
neu1 = 0
neuron2 = (n2 * wegt3) + (n3 * wegt4)
if neuron2 > 0.1:
neu2 = neuron2
else:
neu2 = 0
neuron3 = (n1 * wegt5) + (n4 * wegt6)
if neuron3 > 0.1:
neu3 = neuron3
else:
neu3 = 0
neuron4 = (n2 * wegt7) + (n3 * wegt8)
if neuron4 > 0.1:
neu4 = neuron4
else:
neu4 = 0

repackage of variables

neu1 = neuron1
neu2 = neuron2
neu3 = neuron3
neu4 = neuron4

#layer 2 weights
wegt1a = 1
wegt2a = 1
wegt3a = -1
wegt4a = 1
wegt5a = 1
wegt6a = -1
wegt7a = 1
wegt8a = 1

#layer 2 neurons
neuron1a = (neu1 * wegt1a) + (neu2 * wegt2a)
if neuron1a > 0.1:
neu1a = neuron1a
else:
neu1a = 0

neuron2a = (neu1 * wegt3a) + (neu2 * wegt4a)
if neuron2a > 0.1:
neu2a = neuron2a
else:
neu2a = 0

neuron3a = (neu3 * wegt5a) + (neu4 * wegt6a)
if neuron3a > 0.1:
neu3a = neuron3a
else:
neu3a = 0

neuron4a = (neu3 * wegt7a) + (neu4 * wegt8a)
if neuron4a > 0.1:
neu4a = neuron4a
else:
neu4a = 0

layer 3 weights

wegt_a = 1
wegt_b = -1
wegt_c = 1
wegt_d = -1
wegt_e = 1
wegt_f = -1
wegt_g = 1
wegt_h = -1

Output neurons

op_neu_1 = neu1a * wegt_a
op_neu_2 = neu1a * wegt_b
op_neu_3 = neu2a * wegt_c
op_neu_4 = neu2a * wegt_d
op_neu_5 = neu3a * wegt_e
op_neu_6 = neu3a * wegt_f
op_neu_7 = neu4a * wegt_g
op_neu_8 = neu4a * wegt_h

print(“Possible patterns recognized”)
print("")
print(“White Solid Detected”)
print(op_neu_1)
print(“Black Solid Detected”)
print(op_neu_2)
print(“Left Black Vertical Detected”)
print(op_neu_3)
print(“Right Black Vertical Detected”)
print(op_neu_4)
print(“Forward Slash Detected”)
print(op_neu_5)
print(“Back Slash Detected”)
print(op_neu_6)
print(“Upper White Horizontal Detected”)
print(op_neu_7)
print(“Lower White Horizontal Detected”)
print(op_neu_8)
print("")
print("")
print("")
print(“First Layer Output”)
print(neuron1)
print(neuron2)
print(neuron3)
print(neuron4)
print(“Second Layer Output”)
print(neu1a)
print(neu2a)
print(neu3a)
print(neu4a)

                                                          Thank You for giving it a look.

#2

You need to revisit programming fundamentals
Loops and Arrays will clean this project up tremendously.