资源简介
python不使用框架实现卷积神经网络识别手写数字, 在100个的测试集上准确率最高可达95%。内含数据集
代码片段和文件信息
# 1. 当为array的时候,默认d*f就是对应元素的乘积,multiply也是对应元素的乘积,dot(df)会转化为矩阵的乘积, dot点乘意味着相加,而multiply只是对应元素相乘,不相加
# 2. 当为mat的时候,默认d*f就是矩阵的乘积,multiply转化为对应元素的乘积,dot(df)为矩阵的乘积
import numpy as np
# rule激活器
class ReluActivator(object):
def forward(self weighted_input):
return max(0 weighted_input.any() / weighted_input.max())
def backward(self output):
return 1 if output > 0 else 0
# IdentityActivator激活器.f(x)=x
class IdentityActivator(object):
def forward(self weighted_input):
return weighted_input
def backward(self output):
return 1
# Sigmoid激活器
class SigmoidActivator(object):
def forward(self weighted_input):
return 1.0 / (1.0 + np.exp(-weighted_input))
def backward(self output):
# return output * (1 - output)
return np.multiply(output (1 - output)) # 对应元素相乘
# tanh激活器
class TanhActivator(object):
def forward(self weighted_input):
return 2.0 / (1.0 + np.exp(-2 * weighted_input)) - 1.0
def backward(self output):
‘‘‘
z = wx + b
output = tanh(z)
返回的是f‘(z)
‘‘‘
return 1 - output * output
# softmax激活器
class SoftmaxActivator(object):
def forward(self weighted_input): # 前向计算,计算输出
exps = np.exp(weighted_input - np.max(weighted_input))
return exps / np.sum(exps)
def backward(self output): # 后向计算,计算导数
return 1 if output > 0 else 0
# if __name__ == “__main__“:
# a = SoftmaxActivator()
# input = np.array([1 2 4 6]).reshape((4 1))
# r = a.forward(input)
# print(r)
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2020-01-08 13:03 CNN1\
文件 1938 2019-12-30 19:24 CNN1\Activators.py
文件 20900 2019-12-30 16:16 CNN1\CNN.py
文件 3595 2019-12-30 19:35 CNN1\DNN.py
文件 5477 2019-12-30 11:18 CNN1\MNIST_loader.py
目录 0 2020-01-06 16:33 CNN1\__pycache__\
文件 2483 2019-12-30 19:24 CNN1\__pycache__\Activators.cpython-37.pyc
文件 8288 2019-12-30 19:23 CNN1\__pycache__\CNN.cpython-37.pyc
文件 1719 2019-12-30 19:35 CNN1\__pycache__\DNN.cpython-37.pyc
文件 3198 2020-01-06 10:40 CNN1\__pycache__\MNIST_loader.cpython-37.pyc
文件 1686 2020-01-06 16:33 CNN1\__pycache__\paint_tools.cpython-37.pyc
文件 10325 2020-01-08 13:03 CNN1\cnn_test.py
文件 37911 2020-01-06 16:49 CNN1\confusion_matrix.png
文件 13932 2020-01-06 16:49 CNN1\loss.png
目录 0 2019-12-30 19:21 CNN1\mnist_data\
文件 7840016 2019-12-25 10:14 CNN1\mnist_data\t10k-images.idx3-ubyte
文件 10008 2019-12-25 10:15 CNN1\mnist_data\t10k-labels.idx1-ubyte
文件 47040016 2019-12-25 10:15 CNN1\mnist_data\train-images.idx3-ubyte
文件 60008 2019-12-25 10:15 CNN1\mnist_data\train-labels.idx1-ubyte
文件 1401 2020-01-06 16:28 CNN1\paint_tools.py
相关资源
- python+ selenium教程
- PycURL(Windows7/Win32)Python2.7安装包 P
- 英文原版-Scientific Computing with Python
- 7.图像风格迁移 基于深度学习 pyt
- 基于Python的学生管理系统
- A Byte of Python(简明Python教程)(第
- Python实例174946
- Python 人脸识别
- Python 人事管理系统
- 基于python-flask的个人博客系统
- 计算机视觉应用开发流程
- python 调用sftp断点续传文件
- python socket游戏
- 基于Python爬虫爬取天气预报信息
- python函数编程和讲解
- Python开发的个人博客
- 基于python的三层神经网络模型搭建
- python实现自动操作windows应用
- python人脸识别(opencv)
- python 绘图(方形、线条、圆形)
- python疫情卡UN管控
- python 连连看小游戏源码
- 基于PyQt5的视频播放器设计
- 一个简单的python爬虫
- csv文件行列转换python实现代码
- Python操作Mysql教程手册
- Python Machine Learning Case Studies
- python获取硬件信息
- 量化交易(附python常见函数的使用方
- python 名字用字排行
评论
共有 条评论