Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ee17d6b

Browse files
authored
Create Dataloader.hpp
1 parent 1a4dc0d commit ee17d6b

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

‎headfile/Dataloader.hpp‎

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
2+
void load_data(){
3+
cout<<"------------加载中------------" <<endl<<endl;
4+
for(int i=0;i<10;i++){
5+
for(int j=1;j<=number;j++){
6+
PIMAGE p=newimage();
7+
string dir="";
8+
dir="mnist_images\\";
9+
dir+=char(i+'0');
10+
dir+="\\";
11+
dir+=to_string(j);
12+
dir+=".png";
13+
cout<<"finish:"<<dir<<endl;
14+
getimage(p,dir.c_str());
15+
int cnt=0;
16+
for(int y=0;y<28;y++){
17+
for(int x=0;x<28;x++){
18+
color_t color=getpixel(x,y,p);
19+
int value=EGEGET_R(color)+EGEGET_G(color)+EGEGET_B(color);
20+
value/=3;
21+
ima[i][j][cnt++]=1.0*value/255.0;
22+
}
23+
}
24+
delimage(p);
25+
}
26+
27+
for(int j=1;j<=10;j++){
28+
PIMAGE p=newimage();
29+
string dir="";
30+
dir="mnist_images\\";
31+
dir+=char(i+'0');
32+
dir+="\\";
33+
dir+=to_string(j+number+20);
34+
dir+=".png";
35+
cout<<"finish:"<<dir<<endl;
36+
getimage(p,dir.c_str());
37+
int cnt=0;
38+
for(int y=0;y<28;y++){
39+
for(int x=0;x<28;x++){
40+
color_t color=getpixel(x,y,p);
41+
int value=EGEGET_R(color)+EGEGET_G(color)+EGEGET_B(color);
42+
value/=3;
43+
ima[i+10][j][cnt++]=1.0*value/255.0;
44+
}
45+
}
46+
delimage(p);
47+
}
48+
}
49+
50+
51+
cout<<endl<<"------------加载完毕------------" <<endl;
52+
return;
53+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /