mirror of
https://github.com/marian-nmt/marian.git
synced 2024-09-11 06:15:56 +03:00
ReadLabels() return vector of floats
This commit is contained in:
parent
5c7c044dd9
commit
6a8d5c1997
@ -26,99 +26,9 @@
|
||||
</natures>
|
||||
<linkedResources>
|
||||
<link>
|
||||
<name>CMakeLists.txt</name>
|
||||
<type>1</type>
|
||||
<locationURI>PARENT-1-PROJECT_LOC/src/CMakeLists.txt</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>
|
||||
<name>src</name>
|
||||
<type>2</type>
|
||||
<locationURI>PARENT-1-PROJECT_LOC/src</locationURI>
|
||||
</link>
|
||||
</linkedResources>
|
||||
</projectDescription>
|
||||
|
@ -46,7 +46,7 @@ std::vector<float> ReadImages(const std::string& full_path, int& number_of_image
|
||||
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);
|
||||
|
||||
if (! file.is_open())
|
||||
@ -62,9 +62,11 @@ std::vector<int> 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<int> _dataset(number_of_labels);
|
||||
std::vector<float> _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;
|
||||
|
@ -30,7 +30,7 @@ int main(int argc, char** argv) {
|
||||
|
||||
int 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;
|
||||
tx.Load(images);
|
||||
//ty.Load(labels);
|
||||
|
Loading…
Reference in New Issue
Block a user