资源简介
前端用画布手写,后台传送到服务器,简单的神经网络手写识别。前端用画布手写,后台传送到服务器,简单的神经网络手写识别。前端用画布手写,后台传送到服务器,简单的神经网络手写识别。前端用画布手写,后台传送到服务器,简单的神经网络手写识别。前端用画布手写,后台传送到服务器,简单的神经网络手写识别。前端用画布手写,后台传送到服务器,简单的神经网络手写识别。前端用画布手写,后台传送到服务器,简单的神经网络手写识别。前端用画布手写,后台传送到服务器,简单的神经网络手写识别。前端用画布手写,后台传送到服务器,简单的神经网络手写识别。前端用画布手写,后台传送到服务器,简单的神经网络手写识别。
代码片段和文件信息
import csv
import matplotlib.pyplot as plt
import matplotlib.cm as cm
import numpy as np
import math
import random
import os
import json
from numpy import matrix
from math import pow
from collections import namedtuple
class HCRNN:
LEARNING_RATE = 0.1
WIDTH_IN_PIXELS = 20
NN_FILE_PATH = ‘./nn.json‘
def __init__(self num_hidden_nodes data_matrix data_labels training_indices use_file=True):
self.sigmoid = np.vectorize(self._sigmoid_scalar)
self.sigmoid_prime = np.vectorize(self._sigmoid_prime_scalar)
self._use_file = use_file
self.data_matrix = data_matrix
self.data_labels = data_labels
if (not os.path.isfile(HCRNN.NN_FILE_PATH) or not use_file):
#初始化权重偏置
self.theta1 = self._rand_initialize_weights(400 num_hidden_nodes)
self.theta2 = self._rand_initialize_weights(num_hidden_nodes 10)
self.input_layer_bias = self._rand_initialize_weights(1 num_hidden_nodes)
self.hidden_layer_bias = self._rand_initialize_weights(1 10)
#开始训练
TrainData = namedtuple(‘TrainData‘ [‘y0‘ ‘label‘])
self.train([TrainData(self.data_matrix[i] int(self.data_labels[i])) for i in training_indices])
self.save()
else:
self._load()
def _rand_initialize_weights(self size_in size_out):
return [((x * 0.12) - 0.06) for x in np.random.rand(size_out size_in)]
#s激励函数
def _sigmoid_scalar(self z):
return 1 / (1 + math.e ** -z)
def _sigmoid_prime_scalar(self z):
return self.sigmoid(z) * (1 - self.sigmoid(z))
def train(self training_data_array):
for data in training_data_array:
#前向传播
y1 = np.dot(np.mat(self.theta1) np.mat(data[‘y0‘]).T)
#添加偏置
sum1 = y1 + np.mat(self.input_layer_bias)
y1 = self.sigmoid(sum1)
y2 = np.dot(np.array(self.theta2) y1)
#添加偏置
y2 = np.add(y2 self.hidden_layer_bias)
y2 = self.sigmoid(y2)
#反向传播
actual_vals = [0] * 10
actual_vals[data[‘label‘]] = 1
output_errors = np.mat(actual_vals).T - np.mat(y2)
hidden_errors = np.multiply(np.dot(np.mat(self.theta2).T output_errors) self.sigmoid_prime(sum1))
#更新权重
self.theta1 += self.LEARNING_RATE * np.dot(np.mat(hidden_errors) np.mat(data[‘y0‘]))
self.theta2 += self.LEARNING_RATE * np.dot(np.mat(output_errors) np.mat(y1).T)
self.hidden_layer_bias += self.LEARNING_RATE * output_errors
self.input_layer_bias += self.LEARNING_RATE * hidden_errors
def predict(self test):
y1 = np.dot(np.mat(self.theta1) np.mat(test).T)
y1 = y1 + np.mat(self.input_layer_bias)
y1 = self.sigmoid(y1)
y2 = np.dot(np.array(self.theta2) y1)
y2 = np.add(y2 self.hidden_layer_bias)
y2 = self.sigmoi
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 410 2018-06-18 02:00 HandWritingCharRecognition\.vscode\launch.json
文件 26337792 2017-02-11 13:21 HandWritingCharRecognition\data.csv
文件 10000 2017-02-11 13:21 HandWritingCharRecognition\dataLabels.csv
文件 129 2018-06-18 02:04 HandWritingCharRecognition\hcr.css
文件 741 2018-06-18 02:03 HandWritingCharRecognition\HCR.html
文件 4266 2018-06-18 01:23 HandWritingCharRecognition\Hcr.js
文件 4026 2018-06-18 01:53 HandWritingCharRecognition\hcr.py
文件 132685 2018-06-18 01:54 HandWritingCharRecognition\nn.json
文件 1090 2018-06-18 02:11 HandWritingCharRecognition\nnnodechoice.py
文件 1699 2018-06-18 02:10 HandWritingCharRecognition\Server.py
文件 4303 2018-06-18 01:53 HandWritingCharRecognition\__pycache__\hcr.cpython-36.pyc
目录 0 2018-06-18 02:14 HandWritingCharRecognition\.vscode
目录 0 2018-06-18 02:14 HandWritingCharRecognition\__pycache__
目录 0 2018-06-18 02:14 HandWritingCharRecognition
----------- --------- ---------- ----- ----
26497141 14
相关资源
- Antenna Theory Balanis Answers
- Canny算子分割遥感影像
- Constantine Balanis-Introduction to Smart Ante
- HTKbook-3.5版本,增加DNN识别
- Juniper Networks Network Connect 7.1.0.17943 x
- sublime汉化包,packagecontrolchannel_v3.js
- 朱志刚译《中文-数字图像处理》美
- ulipad.4.1 for linux
- Understanding LSTM Networks
- Setup for TheBestSpinner
- 机器学习实战之K邻近算法
- Hyperion planning
- 图像融合 CNN.zip
- ClassMate.zip
- anyconnect-win-4.7.04056-core-vpn-webdeploy-k9
- Bentley MicroStation CONNECT版Update410.00.00
- tensorflow深度学习CNN智能识别车牌
- CUDA9.2及cudnn7.1 for win10
- Tensorflow GNN实战.zip
- AT-GAN:A Generative Attack Model译文
- G2810清零.rar
- ANSI-VITA 66.0-2016 Optical Interconnect on VP
- 互联网各厂运维方向面试题汇总附答
- ANN: Approximate Nearest Neighbors近似最近邻
- 李宏毅课件卷积神经网络CNN课件笔记
- ROBOTICS:modellingplanning and control
- Ogre+3d+1.7+beginner+Guide 中英对照.pdf
- A Computational Approach to Edge Detection
- Winconnect server xp SP3
- Data Analytics for Beginners: Basic Guide to M
评论
共有 条评论