程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

[Python] use numpy for in-depth learning to recognize handwritten digits

編輯:Python

NeuralNetwork-Numpy
Code download link : The code download

pattern recognition Use numpy Deep learning

 Please refer to main.ipynb

Network core

net.py
conv.py

Usage method

 Defining network
from net import ConvNet
net = ConvNet()
if not net.load(MODEL_PATH):
net.addConvLayout([3,3,1,4],bias = True,padding='VAILD',init_type=init_type,st_func='LEAKY_RELU_0.01')
net.addConvLayout([3,3,4,8],bias = True,padding='VAILD',init_type=init_type,st_func='LEAKY_RELU_0.01')
net.addConvLayout([5,5,8,16],bias = True,padding='VAILD',init_type=init_type,st_func='LEAKY_RELU_0.01')
net.addConvLayout([5,5,16,32],bias = True,padding='VAILD',init_type=init_type,st_func='LEAKY_RELU_0.01')
net.addConvLayout([16,16,32,64],bias = True,padding='VAILD',st_func='SIGMOID',init_type=init_type)
net.addConvLayout([1,1,64,10],bias = True,padding='VAILD',st_func='SIGMOID',init_type=init_type)
addData(): Add data
addConvLayout(): Add a layer of network at the end of the current network

Support convolution layer , Fully connected layer ,Batch Normalization layer

The activation function supports sigmoid,leaky_relu_alpha,alpha It can be any value

regress(): Return to

Support MSE And cross entropy Support multiple optimizers (SGD,Nesterov,RMSProp)

count(): Calculate the output of each layer
save(): Save weights
load(): Weight reading

function mnist_train Experience training

test.py Visual output of

Network structure output

print(net) Output network structure

notes : Required before input addData(), and count once

mnist Visual output

 function mnist_visual_test.py Testable mnist Data sets
model Inside the folder is mnist Training model , The latest model is only in batch_size=30 Training under the circumstances of 400 Time , Our test accuracy on the test set has reached :95.38%. The model structure used is shown in the figure above ,4 Convolution layer +2 Layer full connection layer .




function main.ipynb Conduct personalized testing


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved