Python請進
- print('實作單一神經元python計算')
- from numpy import *
- def sigmoid(x):
- return 1/(1+exp(-x))
- def relu(x):
- return max(0, x)
- x=array([ 1, 1, 0])
- w=array([3, 2, 6])
- b=-4
- #算內積 x, w
- x@w
- x.dot(w)
- def f(x, w, b):
- return x@w+b
- f(x, w, b)
- z=f(array([ 0, 1, 0]), w, -5)
- z
- sigmoid(z)
- relu(z)
- relu(f(array([ 0, 1, 1]), w, b))
沒有留言:
張貼留言