Skip to content

Commit

Permalink
modified reading mnist data
Browse files Browse the repository at this point in the history
  • Loading branch information
TE-NaokiIde committed Apr 25, 2019
1 parent dcf3357 commit 802f88a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions examples/cpp/mnist_collection/mnist_data.hpp
Expand Up @@ -35,12 +35,12 @@ vector<vector<uint8_t>> read_images(const string &train,

gzFile fp = gzopen((data_root + filename).c_str(), "rb");
if (fp == NULL) {
cerr << "This sample requires mnist data downloaded before.";
cerr << "This sample requires mnist data downloaded before." << endl;
exit(0);
}

int header;
gzread(fp, (char *)&header, 4 * sizeof(int));
char header[16];
gzread(fp, header, 16);
int num_images = 60000;
if (train == "test")
num_images = 10000;
Expand Down Expand Up @@ -69,12 +69,12 @@ vector<uint8_t> read_labels(const string &train, const string &data_root,

gzFile fp = gzopen((data_root + filename).c_str(), "rb");
if (fp == NULL) {
cerr << "This sample requires mnist data downloaded before. ";
cerr << "This sample requires mnist data downloaded before." << endl;
exit(0);
}

int header;
gzread(fp, (char *)&header, 2 * sizeof(int));
char header[8];
gzread(fp, header, 8);
int num_images = 60000;
if (train == "test")
num_images = 10000;
Expand Down
12 changes: 6 additions & 6 deletions examples/cpp/mnist_training/mnist_training.hpp
Expand Up @@ -40,12 +40,12 @@ vector<vector<uint8_t>> read_images(const string &data_root,

gzFile fp = gzopen((data_root + filename).c_str(), "rb");
if (fp == NULL) {
cerr << "This sample requires mnist data downloaded before.";
cerr << "This sample requires mnist data downloaded before." << endl;
exit(0);
}

int header;
gzread(fp, (char *)&header, 4 * sizeof(int));
char header[16];
gzread(fp, header, 16);
int num_images = 60000;
int num_rows = 28;
int num_cols = 28;
Expand All @@ -69,12 +69,12 @@ vector<uint8_t> read_labels(const string &data_root, const string &filename) {

gzFile fp = gzopen((data_root + filename).c_str(), "rb");
if (fp == NULL) {
cerr << "This sample requires mnist data downloaded before. ";
cerr << "This sample requires mnist data downloaded before." << endl;
exit(0);
}

int header;
gzread(fp, (char *)&header, 2 * sizeof(int));
char header[8];
gzread(fp, header, 8);
int num_images = 60000;

vector<uint8_t> labels;
Expand Down

0 comments on commit 802f88a

Please sign in to comment.