Explan

  • Language:Python
  • This is about neure
import numpy as np
def ANDS(x1,x2):
    x=np.array([x1,x2])
    w=np.array([0.4,0.4])
    b=-0.6
    temp=np.sum(w*x)+b
    if(temp<=0):
        return 0
    else:
        return 1
def ORS(x1,x2):
    x=np.array([x1,x2])
    w=np.array([0.4,0.5])
    b=0
    temp=np.sum(w*x)+b
    if(temp<=0):
        return 0
    else:
        return 1
def NANDS(x1,x2):
    x=np.array([x1,x2])
    w=np.array([-0.4,-0.4])
    b=0.6
    temp=np.sum(w*x)+b
    if(temp<=0):
        return 0
    else:
        return 1
def XORS(x1,x2):
    s1=NANDS(x1,x2)
    s2=ORS(x1,x2)
    return ANDS(s1,s2)

#debug:
print(XORS(1,1))