Exemplo n.º 1
0
import numpy as np
from Perceptron1 import Perceptron

trainin_inputs = []
trainin_inputs.append(np.array([1,1,1]))
trainin_inputs.append(np.array([0,1,0]))
trainin_inputs.append(np.array([1,0,1]))
trainin_inputs.append(np.array([0,0,0]))
trainin_inputs.append(np.array([0,0,1]))
trainin_inputs.append(np.array([0,1,1]))

labels = np.array([1,0,0,0,0,0])

perceptron = Perceptron(3)
perceptron.train(trainin_inputs,labels)

inputs = np.array([1,1,0])
print(" [1,1,0] ",perceptron.predict(inputs))

inputs = np.array([1,0,0])
print(" [1,0,0] ",perceptron.predict(inputs))
Exemplo n.º 2
0
import numpy as np
from Perceptron1 import Perceptron

trainin_inputs = []
trainin_inputs.append(np.array([0,0,0]))
trainin_inputs.append(np.array([0,0,1]))
trainin_inputs.append(np.array([0,1,0]))
trainin_inputs.append(np.array([0,1,1]))
trainin_inputs.append(np.array([1,0,0]))
trainin_inputs.append(np.array([1,0,1]))
trainin_inputs.append(np.array([1,1,0]))
trainin_inputs.append(np.array([1,1,1]))

labels = np.array([0,0,0,0,0,1,1,1])

perceptron = Perceptron(3)
perceptron.train(trainin_inputs,labels)

print(" Inputs\t\tOutput")
inputs = np.array([1,1,0])
print("============================================================")
print(" [1,1,0]\t",perceptron.predict(inputs))
if (perceptron.predict(inputs) == 1):
    print("Conclusion: We will play Soccer")
print("============================================================")
inputs = np.array([1,0,0])
print(" [1,0,0]\t",perceptron.predict(inputs))
if (perceptron.predict(inputs) == 0):
    print("Conclusion: We will not play Soccer")
print("============================================================")
Exemplo n.º 3
0
import numpy as np
from Perceptron1 import Perceptron

training_inputs = []
training_inputs.append(np.array([1,1]))
training_inputs.append(np.array([1,0]))
training_inputs.append(np.array([0,1]))
training_inputs.append(np.array([0,0]))


labels = np.array([1,0,0,0])

Perceptron1 = Perceptron(2)
Perceptron1.train(training_inputs,labels)


inputs = np.array([1,1])
print(Perceptron1.predict(inputs))

inputs = np.array([0,1])
print(Perceptron1.predict(inputs))

print("final weights --> " + Perceptron1.weights)

'''
1) for learning rate 0.01 and thresold =5
--------------------
Epoch number :0
weights --->  [0. 0. 0.]
--------------------
Epoch number :1
Exemplo n.º 4
0
import numpy as np
from Perceptron1 import Perceptron

training_inputs = []
training_inputs.append(np.array([0, 0]))
training_inputs.append(np.array([0, 1]))
training_inputs.append(np.array([1, 0]))
training_inputs.append(np.array([1, 1]))

labels = np.array([0, 1, 1, 0])

perceptron = Perceptron(2)
perceptron.train(training_inputs, labels)

inputs = np.array([0, 0])
print(perceptron.predict(inputs))