mnist-java


自己用java代码写的识别手写数字的全连接的神经网络
资源截图
代码片段和文件信息
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class DeepLearn3Test {
static List trains = null ;
static List tests = null;
public static void main(String[] args) {
//load mnist
ReadFile rf1=new ReadFile(“train-labels.idx1-ubyte““train-images.idx3-ubyte“);
ReadFile rf2=new ReadFile(“t10k-labels.idx1-ubyte““t10k-images.idx3-ubyte“);
try {
tests = rf2.loadDigitImages();
trains =rf1.loadDigitImages();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}


int size[]={784402010};
NeuralNetwork network = new NeuralNetwork(size);
network.radomInitWandB();

double image[] = new double[784];

for(int kk=0;kk<10;kk++){
//first: set input
for(int count=0;count for(int i=0;i<784;i++){
image[i] = (int)(trains.get(count).imageData[i]&0xff);
}
network.setInput(image);
//second: forward cal output
double[] output = network.forwardProc();
//third: backward cal delta
double[] y = new double[10];
for(int i=0;i if(i==trains.get(count).label){
y[i] = 1;
}else{
y[i] = 0;
}
}
network.backwarkProc(y);
//fouth: update w and b
network.updateWAndB(0.5);
}
System.out.println(“finished train count: “+kk);
}




boolean isTest = true;
//test
if(isTest){
int countCorrect=0;
for(int count=0;count for(int i=0;i<784;i++){
image[i] = (int)(tests.get(count).imageData[i]&0xff);
}
network.setInput(image);
//second: forward cal output
int number = network.testDigitalImage();
if(number==tests.get(count).label)countCorrect++;
//System.out.println(“count is : “+count+“  number is: “+number+“  label is:  “+tests.get(count).label);
}
System.out.println(“countCorrect: “+countCorrect);
}

}
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2017-05-19 19:51  DeepLearn3Test
     文件         301  2017-05-19 09:18  DeepLearn3Test.classpath
     目录           0  2017-05-20 16:45  DeepLearn3Test.git
     文件          25  2017-05-20 16:44  DeepLearn3Test.gitCOMMIT_EDITMSG
     文件         370  2017-05-20 16:45  DeepLearn3Test.gitconfig
     文件          73  2017-05-19 16:36  DeepLearn3Test.gitdescription
     文件          23  2017-05-19 16:36  DeepLearn3Test.gitHEAD
     目录           0  2017-05-19 16:36  DeepLearn3Test.githooks
     文件         478  2017-05-19 16:36  DeepLearn3Test.githooksapplypatch-msg.sample
     文件         896  2017-05-19 16:36  DeepLearn3Test.githookscommit-msg.sample
     文件         189  2017-05-19 16:36  DeepLearn3Test.githookspost-update.sample
     文件         424  2017-05-19 16:36  DeepLearn3Test.githookspre-applypatch.sample
     文件        1642  2017-05-19 16:36  DeepLearn3Test.githookspre-commit.sample
     文件        1348  2017-05-19 16:36  DeepLearn3Test.githookspre-push.sample
     文件        4951  2017-05-19 16:36  DeepLearn3Test.githookspre-rebase.sample
     文件         544  2017-05-19 16:36  DeepLearn3Test.githookspre-receive.sample
     文件        1239  2017-05-19 16:36  DeepLearn3Test.githooksprepare-commit-msg.sample
     文件        3610  2017-05-19 16:36  DeepLearn3Test.githooksupdate.sample
     文件        2309  2017-05-20 16:44  DeepLearn3Test.gitindex
     目录           0  2017-05-19 16:36  DeepLearn3Test.gitinfo
     文件         240  2017-05-19 16:36  DeepLearn3Test.gitinfoexclude
     目录           0  2017-05-19 16:40  DeepLearn3Test.gitlogs
     文件         476  2017-05-20 16:44  DeepLearn3Test.gitlogsHEAD
     目录           0  2017-05-19 16:41  DeepLearn3Test.gitlogs
efs
     目录           0  2017-05-19 16:40  DeepLearn3Test.gitlogs
efsheads
     文件         476  2017-05-20 16:44  DeepLearn3Test.gitlogs
efsheadsmaster
     目录           0  2017-05-19 16:41  DeepLearn3Test.gitlogs
efs
emotes
     目录           0  2017-05-19 16:41  DeepLearn3Test.gitlogs
efs
emotesorigin
     文件         435  2017-05-20 16:45  DeepLearn3Test.gitlogs
efs
emotesoriginmaster
     目录           0  2017-05-20 16:44  DeepLearn3Test.gitobjects
     目录           0  2017-05-20 16:44  DeepLearn3Test.gitobjects4
............此处省略112个文件信息

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。

发表评论

评论列表(条)