mirror of
https://github.com/marian-nmt/marian.git
synced 2024-09-17 09:47:34 +03:00
ReadLabels() return vector of floats
This commit is contained in:
parent
5c7c044dd9
commit
6a8d5c1997
@ -26,99 +26,9 @@
|
|||||||
</natures>
|
</natures>
|
||||||
<linkedResources>
|
<linkedResources>
|
||||||
<link>
|
<link>
|
||||||
<name>CMakeLists.txt</name>
|
<name>src</name>
|
||||||
<type>1</type>
|
<type>2</type>
|
||||||
<locationURI>PARENT-1-PROJECT_LOC/src/CMakeLists.txt</locationURI>
|
<locationURI>PARENT-1-PROJECT_LOC/src</locationURI>
|
||||||
</link>
|
|
||||||
<link>
|
|
||||||
<name>compile_time_crc32.h</name>
|
|
||||||
<type>1</type>
|
|
||||||
<locationURI>PARENT-1-PROJECT_LOC/src/compile_time_crc32.h</locationURI>
|
|
||||||
</link>
|
|
||||||
<link>
|
|
||||||
<name>definitions.h</name>
|
|
||||||
<type>1</type>
|
|
||||||
<locationURI>PARENT-1-PROJECT_LOC/src/definitions.h</locationURI>
|
|
||||||
</link>
|
|
||||||
<link>
|
|
||||||
<name>exception.cpp</name>
|
|
||||||
<type>1</type>
|
|
||||||
<locationURI>PARENT-1-PROJECT_LOC/src/exception.cpp</locationURI>
|
|
||||||
</link>
|
|
||||||
<link>
|
|
||||||
<name>exception.h</name>
|
|
||||||
<type>1</type>
|
|
||||||
<locationURI>PARENT-1-PROJECT_LOC/src/exception.h</locationURI>
|
|
||||||
</link>
|
|
||||||
<link>
|
|
||||||
<name>expression_operators.h</name>
|
|
||||||
<type>1</type>
|
|
||||||
<locationURI>PARENT-1-PROJECT_LOC/src/expression_operators.h</locationURI>
|
|
||||||
</link>
|
|
||||||
<link>
|
|
||||||
<name>expressions.cu</name>
|
|
||||||
<type>1</type>
|
|
||||||
<locationURI>PARENT-1-PROJECT_LOC/src/expressions.cu</locationURI>
|
|
||||||
</link>
|
|
||||||
<link>
|
|
||||||
<name>expressions.h</name>
|
|
||||||
<type>1</type>
|
|
||||||
<locationURI>PARENT-1-PROJECT_LOC/src/expressions.h</locationURI>
|
|
||||||
</link>
|
|
||||||
<link>
|
|
||||||
<name>graph.h</name>
|
|
||||||
<type>1</type>
|
|
||||||
<locationURI>PARENT-1-PROJECT_LOC/src/graph.h</locationURI>
|
|
||||||
</link>
|
|
||||||
<link>
|
|
||||||
<name>graph_operators.h</name>
|
|
||||||
<type>1</type>
|
|
||||||
<locationURI>PARENT-1-PROJECT_LOC/src/graph_operators.h</locationURI>
|
|
||||||
</link>
|
|
||||||
<link>
|
|
||||||
<name>keywords.h</name>
|
|
||||||
<type>1</type>
|
|
||||||
<locationURI>PARENT-1-PROJECT_LOC/src/keywords.h</locationURI>
|
|
||||||
</link>
|
|
||||||
<link>
|
|
||||||
<name>marian.h</name>
|
|
||||||
<type>1</type>
|
|
||||||
<locationURI>PARENT-1-PROJECT_LOC/src/marian.h</locationURI>
|
|
||||||
</link>
|
|
||||||
<link>
|
|
||||||
<name>mnist.h</name>
|
|
||||||
<type>1</type>
|
|
||||||
<locationURI>PARENT-1-PROJECT_LOC/src/mnist.h</locationURI>
|
|
||||||
</link>
|
|
||||||
<link>
|
|
||||||
<name>tensor.cu</name>
|
|
||||||
<type>1</type>
|
|
||||||
<locationURI>PARENT-1-PROJECT_LOC/src/tensor.cu</locationURI>
|
|
||||||
</link>
|
|
||||||
<link>
|
|
||||||
<name>tensor.h</name>
|
|
||||||
<type>1</type>
|
|
||||||
<locationURI>PARENT-1-PROJECT_LOC/src/tensor.h</locationURI>
|
|
||||||
</link>
|
|
||||||
<link>
|
|
||||||
<name>tensor_operators.cu</name>
|
|
||||||
<type>1</type>
|
|
||||||
<locationURI>PARENT-1-PROJECT_LOC/src/tensor_operators.cu</locationURI>
|
|
||||||
</link>
|
|
||||||
<link>
|
|
||||||
<name>tensor_operators.h</name>
|
|
||||||
<type>1</type>
|
|
||||||
<locationURI>PARENT-1-PROJECT_LOC/src/tensor_operators.h</locationURI>
|
|
||||||
</link>
|
|
||||||
<link>
|
|
||||||
<name>test.cu</name>
|
|
||||||
<type>1</type>
|
|
||||||
<locationURI>PARENT-1-PROJECT_LOC/src/test.cu</locationURI>
|
|
||||||
</link>
|
|
||||||
<link>
|
|
||||||
<name>thrust_functions.h</name>
|
|
||||||
<type>1</type>
|
|
||||||
<locationURI>PARENT-1-PROJECT_LOC/src/thrust_functions.h</locationURI>
|
|
||||||
</link>
|
</link>
|
||||||
</linkedResources>
|
</linkedResources>
|
||||||
</projectDescription>
|
</projectDescription>
|
||||||
|
@ -46,7 +46,7 @@ std::vector<float> ReadImages(const std::string& full_path, int& number_of_image
|
|||||||
return _dataset;
|
return _dataset;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<int> ReadLabels(const std::string& full_path) {
|
std::vector<float> ReadLabels(const std::string& full_path) {
|
||||||
std::ifstream file(full_path);
|
std::ifstream file(full_path);
|
||||||
|
|
||||||
if (! file.is_open())
|
if (! file.is_open())
|
||||||
@ -62,9 +62,11 @@ std::vector<int> ReadLabels(const std::string& full_path) {
|
|||||||
int number_of_labels = 0;
|
int number_of_labels = 0;
|
||||||
file.read((char *)&number_of_labels, sizeof(number_of_labels)), number_of_labels = reverseInt(number_of_labels);
|
file.read((char *)&number_of_labels, sizeof(number_of_labels)), number_of_labels = reverseInt(number_of_labels);
|
||||||
|
|
||||||
std::vector<int> _dataset(number_of_labels);
|
std::vector<float> _dataset(number_of_labels);
|
||||||
for (int i = 0; i < number_of_labels; i++) {
|
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;
|
return _dataset;
|
||||||
|
@ -30,7 +30,7 @@ int main(int argc, char** argv) {
|
|||||||
|
|
||||||
int numImg, imgSize;
|
int numImg, imgSize;
|
||||||
vector<float> images = datasets::mnist::ReadImages("../examples/mnist/t10k-images-idx3-ubyte", numImg, imgSize);
|
vector<float> images = datasets::mnist::ReadImages("../examples/mnist/t10k-images-idx3-ubyte", numImg, imgSize);
|
||||||
vector<int> labels = datasets::mnist::ReadLabels("../examples/mnist/t10k-labels-idx1-ubyte");
|
vector<float> labels = datasets::mnist::ReadLabels("../examples/mnist/t10k-labels-idx1-ubyte");
|
||||||
cerr << "images=" << images.size() << " labels=" << labels.size() << endl;
|
cerr << "images=" << images.size() << " labels=" << labels.size() << endl;
|
||||||
tx.Load(images);
|
tx.Load(images);
|
||||||
//ty.Load(labels);
|
//ty.Load(labels);
|
||||||
|
Loading…
Reference in New Issue
Block a user