# 简单的人工神经网络(ANN)设计
```python
import numpy as np
import matplotlib.pyplot as mp
class ANNModel():
def __init__(self):
# 随机初始化权重[-1 1)
self.w0 = 2 * np.random.random((2, 4)) - 1
self.w1 = 2 * np.random.random((4, 1)) - 1
# 学习率
self.lrate = 0.1
# sigmiod 函数
def active(self, x):
return 1 / (1 + np.exp(-x))
# sigmoid函数导函数
def backward(self, x):
return x * (1 - x)
# 单层网路前向传播
def forward(self, x, w):
return np.dot(x, w)
Python实现人工神经网络(ANN)基本API
最新推荐文章于 2024-05-13 08:44:21 发布