前向传播
Example Feed-forward computation of a Neural Network
# -*- coding: utf-8 -*-
"""
Created on Wed Dec 21 21:18:19 2016
@author: CrazyVertigo
"""
import numpy as np
W1 = np.array([[1,1,1],[1,1,1],[1,1,1],[1,1,1]])
W2 = np.array([[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]])
W3 = np.array([1,1,1,1])
b1 =1
b2 =1
b3 =1
f = lambda x: 1.0/(1.0 +np.exp(-x))
x = np.random.randn(3,1)
#print "x=",x
h1 = f(np.dot(W1,x) + b1)
#print "h1=",h1
h2 = f(np.dot(W2,h1) +b2)
#print "h2=",h2
out = np.dot(W3,h2) + b3
#print "out=",out