import numpy as np
def andActivator(x):
if x > 0:
return 1
else:
return 0
class ganzhiji(object):
def init(self, x):
self.x = x
self.w = np.random.rand(2, 1)
self.b = np.random.rand(1, 1)
def forward(self):
self.y = np.zeros((4, 1))
for i in range(self.x.shape[0]):
self.y[i] = andActivator(np.sum(self.x[i] * self.w + self.b))
def backward(self, t, lr):
delt