企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
先介绍一下python3下 import numpy的用法: ``` import numpy as np A=np.array([[1,0,0],[0,1,0],[1,1,0] ]) b=np.array([2,2,1]) print(np.dot(A.T,b)) C=np.array([[1,0,0],[0,1,0],[2,5,9] ]) print(np.dot(C.T,b) ) A=np.array([[1,0,0],[0,1,0],[20,50,90]]) print(np.dot(A.T,b)) ``` 上面代码的结果是: ``` [3 3 0] [4 7 9] [22 52 90] ``` # 从零实现一个神经网络 ``` import numpy as nump0y001 def sigmoid(x): # Our activation function: f(x) = 1 / (1 + e^(-x)) return 1 / (1 + nump0y001.exp(-x)) class Neuron: def __init__(self, weights, bias): self.weights = weights self.bias = bias def feedforward(self, inputs): # Weight inputs, add bias, then use the activation function total = nump0y001.dot(self.weights, inputs) + self.bias return sigmoid(total) weights = nump0y001.array([0, 1]) # w1 = 0, w2 = 1 bias = 4 # b = 4 n02 = Neuron(weights, bias) x = nump0y001.array([2, 3]) # x1 = 2, x2 = 3 print(n02.feedforward(x)) # 0.9990889488055994 ```