标签[ Deep learning ]下的文章


import numpy as np def mean_square_error(input,t): return 0.5*np.sum((input-t)**2) def cross_error(input,t): delta=1e-7 return -np.sum(t*np.log(input)+delta) y=np.array([0.1,0.005,0.1,0.0,0.05,0.1,0.0,0.6,0.0,0.0]) t=np.array([0,0,1,0,0,0,0,0,0,0]) print(mean_square_error(y,...

阅读全文

import numpy as np def Initilize_Net(): nets={} nets['w1']=np.array([[0.1,0.3,0.5],[0.2,0.4,0.6]]) nets['w2']=np.array([[0.1,0.4],[0.2,0.5],[0.3,0.6]]) nets['w3']=np.array([[0.1,0.3],[0.2,0.4]]) nets['b1']=np.array([0.1,0.2,0.3]) nets['b2']=np.array([0.1,0.2]) nets['b3']=np.array([0.1,0.2]) return nets def sigmodis(x): return 1/(1+np.exp(-x)) def softmax(a): c=np.max(a) exp_a=np.exp(a-c) sum_exp=np.sum(exp_a) y=exp_a/sum_exp return y def forword(nets,x): w1,w2,w3=nets['w1'],nets['w2'],nets['w3'] b1,b2,b3=nets['b1'],nets['b2'],nets['b3'] a1=np.dot(x,w1)+b1 z1=sigmodis(a1) a2=np.dot(z1,w2)+b2 z2=sigmodis(a2) a3=np.dot(z2,w3)+b3 y=sigmodis(a3) return y Nets=Initilize_Net() x=np.array([1.0,0.5]) y=forword(Nets,x) print(y) print(softmax(...

阅读全文

FuctionStep-to-step Fuction1,0,1,0Sigmoid FuctionH(x)=1/(1+exp(-x))PictureStep-to-step Fuction Sigmoid FuctionCodeStep-to-step Fuctionimport numpy as np import matplotlib.pylab as plt def step_fuction(x): # x_=[] # for i in x: # if(i>0): # x_.append(1) # else: # x_.append(0) # return x_ return np.array(x>0,dtype=np.int) x=np.arange(-5,5,0.1) # formation -5~5 andArithmetic sequence 0.1 y=step_fuction(x) print(y) plt.plot(x,y) plt.ylim(-0.1,1.1) plt.show() Sigmoid Fuction Fuctionimport numpy as np import matplotlib.pylab as plt def step_fuction(x): return 1/(1+np.exp(-x)) x=np.arange(-5,5,0.1) # formation -5~5 andArithmetic sequence 0.1 y=step_fuction(x) print(y) plt.plot(x,y) plt.ylim(-0.1,1.1) plt.sho...

阅读全文

ExplanLanguage:PythonThis is about neureimport 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...

阅读全文

回到顶部