资源简介
手写汉字识别及其可视化(代码),学习了很长时间的图像处理,选定了一个手写汉字识别的课题。我个人感觉相对于其他任务的识别(比如MNIST,CIFAR-10)难点在于识别种类繁多,在如此繁多的种类中要达到一个很高的识别率确实不容易。

代码片段和文件信息
# encoding: utf-8
‘‘‘
@author: 真梦行路
@file: cnn.py
@time: 18-8-30 下午10:02
‘‘‘
#########################导入第三方库###################################
import time
import math
import random
import os
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import tensorflow as tf
import dataset
import cv2
from sklearn.metrics import confusion_matrix
from datetime import timedelta
###################################加载数据路径########################################
train_path = ‘/home/wcy/图片/python/data/train‘
test_path = ‘/home/wcy/图片/python/data0/test‘
checkpoint_dir = ‘/home/wcy/图片/00/models‘
###################################加载数据路径########################################
############################设定模型参数###########################################
# Convolutional layer 1.
filter_size1 = 3
num_filters1 = 36
# Convolutional layer 2.
filter_size2 = 3
num_filters2 = 36
# Convolutional layer 3.
filter_size3 = 3
num_filters3 = 64
# Fully-connected layer.
fc_size = 256 # Number of neurons in fully-connected layer.
# Number of color channels for the images: 1 channel for gray-scale.
num_channels = 3
# image dimensions (only squares for now)
img_size = 70
# Size of image when flattened to a single dimension
img_size_flat = img_size * img_size * num_channels
# Tuple with height and width of images used to reshape arrays.
img_shape = (img_size img_size)
# class info
# classes = [‘dog‘ ‘cat‘]
classes = os.listdir(train_path)
num_classes = len(classes)
# batch size
batch_size = 1
# validation split
validation_size = .16
# how long to wait after validation loss stops improving before terminating training
early_stopping = None # use None if you don‘t want to implement early stoping
############################设定模型参数###########################################
############################读取数据##############################################
data = dataset.read_train_sets(train_path img_size classes validation_size=validation_size)
test_images test_ids = dataset.read_test_set(test_path img_size)
print(data.train.labels.shape)
print(“Size of:“)
print(“- Training-set:\t\t{}“.format(len(data.train.labels)))
print(“- Test-set:\t\t{}“.format(len(test_images)))
print(“- Validation-set:\t{}“.format(len(data.valid.labels)))
############################读取数据##############################################
######函数##################随机取出9副图显示######################################
def plot_images(images cls_true cls_pred=None):
if len(images) == 0:
print(“no images to show“)
return
else:
random_indices = random.sample(range(len(images)) min(len(images) 9))
images cls_true = zip(*[(images[i] cls_true[i]) for i in random_indices])
# print(‘1111111111111111111‘len(images))
# Create figure with 3x3 sub-plots.
fig axes = plt.subplots(3 3)
fig.subplots_adjust(hspace=0.3 wspace=0.3)
for i ax in enumerate(axes.flat):
# Plot image.
ax.imshow(images[i].reshape(img_size
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 25442 2019-04-11 13:59 dome\cnn.py
文件 155 2019-04-11 14:08 dome\readme
文件 4695 2018-11-21 16:34 dome\dataset.py
文件 569 2018-11-21 19:04 dome\test.py
文件 4554 2018-11-21 16:34 dome\__pycache__\dataset.cpython-35.pyc
文件 1046164 2018-08-31 14:50 dome\.ipynb_checkpoints\cnn-checkpoint.ipynb
目录 0 2019-04-11 14:02 dome\__pycache__
目录 0 2019-04-11 14:02 dome\.ipynb_checkpoints
目录 0 2019-04-11 14:08 dome
----------- --------- ---------- ----- ----
1081579 9
- 上一篇:最后一公里EC配送程序源代码
- 下一篇:精锐IV加密锁驱动64位elite4
相关资源
- TensorFlow1.4 官方手册
- 基于CNN的静态手势识别系统
- 一种基于LBP和CNN的人脸识别算法
- PCNN TOOLBOX
- MSCNN_dehaze.rar
- 基于双向LSTM+tensorflow中文分词
- TensorFlow Machine Learning Cookbook+无码高清
- Hands-On Machine Learning with Scikit-Learn an
- 脉冲耦合神经网络工具箱PCNN-toolbox
- TensorFlow 官方文档中文版高清无码PD
- 卷积神经网络的人脸识别样本采集+
- 基于深度学习的神经网络算法论文
- faster rcnn流程图
- SRCNN翻译学习并改进.zip
- 基于深度学习的图像检索系统CNN
- 超分辨率PPT
- 基于tensorflow的深度学习图像分类案例
- 基于Tensorflow多层神经网络的MNIST手写
- TensorFlow Tutorial
- TensorFlow_2.0快速应用指南英文.tar
- faster_rcnn test 浮点运算量
- 论文研究-基于改进贝叶斯优化算法的
- tensorflow图像风格迁移代码
- darknet文本检测与CNN+CTCOCR文字识别项目
- 超分辨率重建SRCNN(GUI界面)
- 基于多任务卷积网络(MTCNN)和Cente
- 基于深度学习的链路预测
- Mask R-CNN.pptx
- PyTorch介绍及入门pdf
- TensorFlow Machine Learning Cookbook
评论
共有 条评论