构成CNN主要组件思想---BP

方式1:手推写神经元节点的前向、后向计算(参数更新)
import numpy as np

_w = [0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.55, 0.6, 0.65]
_b = [0.35, 0.65]
_x = [5, 10]
_y = [0.01, 0.09]
lr = 0.5

def w(index):
   return _w[index - 1]


def x(index):
   return _x[index - 1]


def b(index):
   return _b[index - 1]


def y(index):
   return _y[index - 1]


def set_w(index, gd):
   _w[index - 1] = _w[index - 1] - lr * gd



def sigmoid(z):
   return 1.0 / (1 + np.exp(-z))


def training():
   # 前向传播节点计算
   neth1 = w(1) * x(1) + w(2) * x(2) + b(1)
   outh1 = sigmoid(neth1)
   neth2 = w(3) * x(1) + w(4) * x(2) + b(1)
   outh2 = sigmoid(neth2)
   neth3 = w(5) * x(1) + w(6) * x(2) + b(1)
   outh3 = sigmoid(neth3)
   neto1 = w(7) * outh1 + w(9) * outh2 + w(11) * outh3 + b(2)
   outo1 = sigmoid(neto1)
   neto2 = w(8) * outh1 + w(10) * outh2 + w(12) * outh3 + b(2)
   outo2 =
  • 3
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值