From 6a8d5c19970a2893e70e1ef25adb66e3ed50d06a Mon Sep 17 00:00:00 2001 From: Hieu Hoang Date: Wed, 14 Sep 2016 08:41:05 +0200 Subject: [PATCH] ReadLabels() return vector of floats --- marian/.project | 96 ++----------------------------------------------- src/mnist.h | 8 +++-- src/test.cu | 2 +- 3 files changed, 9 insertions(+), 97 deletions(-) diff --git a/marian/.project b/marian/.project index e5b195c5..d1163076 100644 --- a/marian/.project +++ b/marian/.project @@ -26,99 +26,9 @@ - CMakeLists.txt - 1 - PARENT-1-PROJECT_LOC/src/CMakeLists.txt - - - compile_time_crc32.h - 1 - PARENT-1-PROJECT_LOC/src/compile_time_crc32.h - - - definitions.h - 1 - PARENT-1-PROJECT_LOC/src/definitions.h - - - exception.cpp - 1 - PARENT-1-PROJECT_LOC/src/exception.cpp - - - exception.h - 1 - PARENT-1-PROJECT_LOC/src/exception.h - - - expression_operators.h - 1 - PARENT-1-PROJECT_LOC/src/expression_operators.h - - - expressions.cu - 1 - PARENT-1-PROJECT_LOC/src/expressions.cu - - - expressions.h - 1 - PARENT-1-PROJECT_LOC/src/expressions.h - - - graph.h - 1 - PARENT-1-PROJECT_LOC/src/graph.h - - - graph_operators.h - 1 - PARENT-1-PROJECT_LOC/src/graph_operators.h - - - keywords.h - 1 - PARENT-1-PROJECT_LOC/src/keywords.h - - - marian.h - 1 - PARENT-1-PROJECT_LOC/src/marian.h - - - mnist.h - 1 - PARENT-1-PROJECT_LOC/src/mnist.h - - - tensor.cu - 1 - PARENT-1-PROJECT_LOC/src/tensor.cu - - - tensor.h - 1 - PARENT-1-PROJECT_LOC/src/tensor.h - - - tensor_operators.cu - 1 - PARENT-1-PROJECT_LOC/src/tensor_operators.cu - - - tensor_operators.h - 1 - PARENT-1-PROJECT_LOC/src/tensor_operators.h - - - test.cu - 1 - PARENT-1-PROJECT_LOC/src/test.cu - - - thrust_functions.h - 1 - PARENT-1-PROJECT_LOC/src/thrust_functions.h + src + 2 + PARENT-1-PROJECT_LOC/src diff --git a/src/mnist.h b/src/mnist.h index 8e94931f..9f867ee8 100644 --- a/src/mnist.h +++ b/src/mnist.h @@ -46,7 +46,7 @@ std::vector ReadImages(const std::string& full_path, int& number_of_image return _dataset; } -std::vector ReadLabels(const std::string& full_path) { +std::vector ReadLabels(const std::string& full_path) { std::ifstream file(full_path); if (! file.is_open()) @@ -62,9 +62,11 @@ std::vector ReadLabels(const std::string& full_path) { int number_of_labels = 0; file.read((char *)&number_of_labels, sizeof(number_of_labels)), number_of_labels = reverseInt(number_of_labels); - std::vector _dataset(number_of_labels); + std::vector _dataset(number_of_labels); for (int i = 0; i < number_of_labels; i++) { - file.read((char*)&_dataset[i], 1); + int label; + file.read((char*)&label, 1); + _dataset[i] = label; } return _dataset; diff --git a/src/test.cu b/src/test.cu index dd65d256..c1f53c02 100644 --- a/src/test.cu +++ b/src/test.cu @@ -30,7 +30,7 @@ int main(int argc, char** argv) { int numImg, imgSize; vector images = datasets::mnist::ReadImages("../examples/mnist/t10k-images-idx3-ubyte", numImg, imgSize); - vector labels = datasets::mnist::ReadLabels("../examples/mnist/t10k-labels-idx1-ubyte"); + vector labels = datasets::mnist::ReadLabels("../examples/mnist/t10k-labels-idx1-ubyte"); cerr << "images=" << images.size() << " labels=" << labels.size() << endl; tx.Load(images); //ty.Load(labels);