def predict(weight, inp): inp = modulate(inp) net = np.dot(weight, inp) predOtp = np.piecewise(net, [net<0, net>0], [-1, 1]) return demodulate(predOtp)