




已阅读5页,还剩42页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
ConvolutionNeuralNetworkCNN,AtutorialKHWong,1,Introduction,VeryPopular:Toolboxes:cuda-convnetandcaffe(userfriendlier)AhighperformanceClassifier(multi-class)SuccessfulinhandwrittenopticalcharacterOCRrecognition,speechrecognition,imagenoiseremovaletc.EasytoimplementationSlowinlearningFastinclassification,2,Overviewofthisnote,Part1:FullyconnectedBackPropagationNeuralNetworks(BPNN)Part1A:feedforwardprocessingPart1A:feedbackwardprocessingPart2:Convolutionneuralnetworks(CNN)Part2A:feedforwardofCNNPart2B:feedbackwardofCNN,3,Part1,FullyConnectedBackPropagation(BP)neuralnet,4,TheoryFullyconnectedBackPropagationNeuralNet(BPNN),Usemanysamplestotraintheweights,soitcanbeusedtoclassifyanunknowninputintodifferentclassesWillexplainHowtouseitaftertraining:forwardpassHowtotrainit:howtotraintheweightsandbiases(usingforwardandbackwardpasses),5,Training,Howtotrainit:howtotraintheweights(W)andbiases(b)(useforward,backwardpasses)InitializeWandbrandomlyIter=1:all_epocks(eachiscalledanepcok)Forwardpassforeachoutputneuron:Usetrainingsamples:Xclass_t:feedforwardtofindy.Err=error_function(y-t)Backwardpass:FindWandbtoreduceErr.Wnew=Wold+W;bnew=bold+b,6,Part1A,ForwardpassofBackPropagationNeuralNet(BPNN)Recall:Forwardpassforeachoutputneuron:-Usetrainingsamples:Xclass_t:feedforwardtofindy.-Err=error_function(y-t),7,FeedforwardofBackPropagationNeuralNet(BPNN),Insideeachneuron:,Outputneurons,Inputs,8,Sigmodfunctionf(u)anditsderivativef(u),9,Asingleneuron,TheneuralnetcanhavemanylayersInbetweenanyneighboring2layers,asetofneuronscanbefound,EachNeuron,10,BPNNForwardpass,Forwardpassistofindoutputwhenaninputisgiven.Forexample:AssumewehaveusedN=60,000imagestotrainanetworktorecognizec=10numerals.Whenanunknownimageisinput,theoutputneuroncorrespondstothecorrectanswerwillgivethehighestoutputlevel.,10outputneuronsfor0,1,2,.,9,Inputimage,11,Thecriteriatotrainanetwork,Isbasedontheoverallerrorfunction,12,StructureofaBPneuralnetwork,Inputlayer,outputlayer,13,Architecture(exercise:writeformulasforA1(i=4)andA2(k=3),Input:P=9x1Indexedbyj,Hiddenlayer=5neurons,indexedbyiW1=9x5b1=5x1,W1(j=1,i=1),W1(j=2,i=1),W1(j=9,i=1),P(j=1)P(j=2)P(j=3):P(j=9),A1(i=1),P(j=1),P(j=2),P(j=9),Neuroni=1Bias=b1(i=1),W2(i=1,k=1),W2(i=2,k=1),W2(i=5,k=1),A2(k=2),A1,A2,A5,Neuronk=1Bias=b2(k=1),W1(j=1,i=1),W1(j=2,i=1),W1(j=9,i=5),W1(j=3,i=4),A1(i=5),A1(i=1),Outputneurons=3neurons,indexedbykW2=5x3b2=3x1,W2(i=5,k=3),W2(i=1,k=1),W2(i=2,k=2),W2(i=2,k=1),A1(i=2),14,Answer(exercise:writevaluesforA1(i=4)andA2(k=3),P=0.76560.73440.96090.99610.91410.90630.09770.09380.0859W1=0.21120.1540-0.0687-0.02890.0720-0.16660.2938-0.0169-0.1127-b1=0.1441%FindA1(i=4)A1_i_is_4=1/(1+exp-(W1*P+b1)=0.49,15,Numericalexamplefortheforwardpath,FeedforwardGivenumbersofx,wbetc,16,Example:asimpleBPNN,Numberofclasses(no.ofoutputneurons)=3Input9pixels:eachinputisa3x3imageTrainingsamples=3foreachclassNumberofhiddenlayers=1Numberofneuronsinthehiddenlayer=5,17,Architectureoftheexample,InputLayer9x1pixels,outputLayer3x1,18,Part1B,BackwardpassofBackPropagationNeuralNet(BPNN),19,feedback,Feedforward,Feedbackward,20,derivation,21,derivation,22,Numericalexampleforthefeedbackpass,23,Procedure,Fromthelastlayer(output),finddt-yFindd,thenfindwofthewholenetworkFinditerative(forward-backforwardpass)togenerateanewsetofW,untildWissmallTakesalongtime,24,Part2ConvolutionNeuralNetworks,Part2AFeedforwardpartofcnnff(),Matlabexample,25,AnexampleopticalcharteredrecognitionOCR,Exampletest_example_CNN.min,26,OverviewofTest_example_CNN.m,ReaddatabasePartI:cnnsetup.mLayer1:inputlayer(donothing)Layer2convolution(conv.)Layer,outputmaps=6,kernelsize=5x5Layer3sub-sample(subs.)Layer,scale=2Layer4conv.Layer,outputmaps=12,kernelsize=5x5Layer5subs.Layer(outputlayer),scale=2Part2:cnntrain.m%trainwedihgtsusing60,000samplescnnff()%CNNfeedforwardcnndb()%CNNfeedbacktotrainweightedinkernelscnnapplygrads()%updateweightscnntest.m%testthesystemusing10000samplesandshowerrorrate,27,Architecture,Eachoutputneuroncorrespondstoacharacter(0,1,2,.,9etc.),Layer1:ImageInput1x28x28,Layer12:6conv.Maps(C)InputMaps=6OutputMaps=6Fan_in=52=25Fan_out=6x52=150,Layer23:6sub-sampleMap(S)InputMaps=6OutputMaps=12,Layer34:12conv.Maps(C)InputMaps=6OutputMaps=12Fan_in=6x52=150Fan_out=12x52=300,Layer45:12sub-sampleMap(S)InputMaps=12OutputMaps=12,Layer1:Oneinput(I),Layer5:12x4x4,10,Kernel=5x5,2x2,Kernel=5x5,Subs,Subs,Layer4:12x8x8,Layer3:6x12x12,Layer2:6x24x24,Conv.,I=inputC=Conv.=convolutionS=Subs=subsampling,Conv.,2x2,28,Cnnff.mconvolutionneuralnetworksfeedforward,ThisisthefeedforwardpartAssumealltheweightsareinitializedorcalculated,weshowhowtogettheoutputfrominputs.,29,Layer12:,Convolutelayer1withdifferentkernels(map_index1=1,2,.,6)andproduce6outputmapsInputs:inputlayer1,a28x28image6differentkernels:k(1),.,k(6),eachkis5x5,KaredendritesofneuronsOutput:6outputmapseach24x24AlgorithmFor(map_index=1:6)layer_2(map_index)=I*k(map_index)validDiscussionValidmeansonlyconsideroverlappedareas,soiflayer1is28x28,kernelis5x5each,eachoutputmapis24x24InMatlabuseconvn(I,k,valid)Example:I=rand(28,28)k=rand(5,5)size(convn(I,k,valid)ans2424,Layer1:ImageInput(i)1x28x28,Layer12:6conv.Maps(C)InputMaps=6OutputMaps=6Fan_in=52=25Fan_out=6x52=150,Layer1:Oneinput(I),Kernel=5x5,2x2,Layer2(c):6x24x24,Conv.*K(6),I=inputC=Conv.=convolutionS=Subs=subsampling,i,j,Map_index=12:6,Conv.*K(1),30,Layer23:,Layer23:6sub-sampleMap(S)InputMaps=6OutputMaps=12,2x2,Subs,Layer3(s):6x12x12,Layer2(c):6x24x24,Sub-samplelayer2tolayer3Inputs:6mapsoflayer2,eachis24x24Output:6mapsoflayer3,eachis12x12AlgorithmFor(map_index=1:6)Foreachinputmap,calculatetheaverageof2x2pixelsandtheresultissavedinoutputmaps.Henceresolutionisreducedfrom24x24to12x12Discussion,Map_index=12:6,31,Layer34:,Layer34:12conv.Maps(C)InputMaps=6OutputMaps=12Fan_in=6x52=150Fan_out=12x52=300,Kernel=5x5,Layer4(c):12x8x8,Layer3L3(s):6x12x12,Conv.layer3withkernelstoproducelayer4Inputs:6mapsoflayer3(L3i=1:6),eachis12x12Kernelset:totally6x12kernels,eachis5x5,i.e.Ki=1:6j=1:12,eachKijis5x512biasj=1:12inthislayer,eachisascalarOutput:12mapsoflayer4(L4j=1:12),eachis8x8Algorithmfor(j=1:12)for(i=1:6)clearz,i.e.z=0;z=z+covn(L3i,kij,valid)%zis8x8L4j=sigm(z+baisj)%L4jis8x8functionX=sigm(P)X=1./(1+exp(-P);EndDiscussionNormalization?,Index=i=1:6,Index=j=1:12,:,net.layersl.aj,32,Layer45,Layer45:12sub-sampleMap(S)InputMaps=12OutputMaps=12,Layer5:12x4x4,10,Subs,Layer4:12x8x8,2x2,Subsamplelayer4tolayer5Inputs:12mapsoflayer4(L4i=1:12),eachis12x8x8Output:12mapsoflayer5(L5j=1:12),eachis4x4AlgorithmSubsampleeach2x2pixelwindowinL4toapixelinL5DiscussionNormalization?,33,Layer5output,Eachoutputneuroncorrespondstoacharacter(0,1,2,.,9etc.)net.om=1:10,Layer45:12sub-sampleMap(S)InputMaps=12OutputMaps=12,Layer5(L5j=1:12:12x4x4=192Totally192pixels,10,Subsamplelayer4tolayer5Inputs:12mapsoflayer5(L5i=1:12),eachis4x4,soL5has192pixelsintotalOutputlayerweights:Net.ffWm=1:10p=1:192,totalnumberofweightsis192Output:10outputneurons(net.om=1:10)AlgorithmForm=1:10%eachoutputneuronclearnet.fvnet.fv=Net.ffWmall192weight.*L5(allcorresponding192pixels)net.om=sign(net.fv+bias)Discussion,:,Totally192weightsforeachoutputneuron,Sameforeachoutputneuron,34,Part2B,Backpropagationpartcnnbp()cnnapplyweight(),35,cnnbp()overview(outputbacktolayer5,Ref:See/wiki/Backpropagation,36,Layer5to4,Expand1x1to2x2,37,Layer4to3,RotatedconvolutionFinddE/dxatlayer3,38,Layer3to2,Expand1x1to2x2,39,Calculategradient,Fromlater2tolayer3Fromlater3tolayer4Net.ffWNet.ffbfound,40,Detailsofcalcgradients,%part%reshapefeaturevectordeltasintooutputmapstyleL4(c)runexpandonlyL3(s)runconv(rot180,fill),founddL2(c)runexpandonly%Part%calcgradientsL2(c)runconv(valid),founddkanddbL3(s)notrunhereL4(c)runconv(valid),founddkanddbDone,foundthesefortheoutputlayerL5:net.dffW=net.od*(net.fv)/size(net.od,2);net.dffb=mean(net.od,2);,41,cnnapplygrads(net,opts),Fortheconvolutionlayers,L2,L4Fromkanddkfindnewk(weights)Frombanddbfindnewb(bias)FortheoutputlayerL5net.ffW=net.ffW-opts.alpha*net.dffW;net.ffb=net.ffb-opts.alpha*net.dffb;opts.alphaistoadjustlearningrate,42,appendix,43,Architecture,Eachoutpu
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 【正版授权】 IEC 60384-14-2:2025 RLV EN Fixed capacitors for use in electronic equipment - Part 14-2: Blank detail specification - Fixed capacitors for electromagnetic interference suppr
- 【正版授权】 IEC 62282-3-201:2025 EN-FR Fuel cell technologies - Part 3-201: Stationary fuel cell power systems - Performance test methods for small fuel cell power systems
- 电仪相关知识培训内容课件
- 甘露醇药理知识培训
- 璧山汽车驾驶技巧知识培训课件
- 2025无固定期限劳动合同书范本
- 基于刘草坡化工厂案例剖析磷化工企业水环境风险评价与管控策略
- 基于分形分析的沪深300指数特征挖掘与股票价格预测效能研究
- 父亲的肖像课件
- 袖阀管注浆加固施工质量保证措施
- 2024年大学生电子版三方协议书模板
- 信息科技大单元教学设计之七年级第一单元探寻互联网新世界
- 生猪屠宰兽医卫生检验人员理论考试题库及答案
- 普通高中体育与健康课程标准
- MOOC 理性思维实训-华南师范大学 中国大学慕课答案
- 《陆上风电场工程设计概算编制规定及费用标准》(NB-T 31011-2019)
- 腾讯组织管理手册
- 《燕麦片营养调查》课件
- 四川大学有机化学习题
- 中药饮片采购和验收和保管和调剂培训课件
- 网络运维从入门到精通29个实践项目详解
评论
0/150
提交评论