AshanGimhana's picture
Upload folder using huggingface_hub
9375c9a verified
raw
history blame
27.3 kB
<html><!-- Created using the cpp_pretty_printer from the dlib C++ library. See http://dlib.net for updates. --><head><title>dlib C++ Library - mnist.cpp</title></head><body bgcolor='white'><pre>
<font color='#009900'>// Copyright (C) 2015 Davis E. King ([email protected])
</font><font color='#009900'>// License: Boost Software License See LICENSE.txt for the full license.
</font><font color='#0000FF'>#ifndef</font> DLIB_MNIST_CPp_
<font color='#0000FF'>#define</font> DLIB_MNIST_CPp_
<font color='#0000FF'>#include</font> "<a style='text-decoration:none' href='mnist.h.html'>mnist.h</a>"
<font color='#0000FF'>#include</font> <font color='#5555FF'>&lt;</font>fstream<font color='#5555FF'>&gt;</font>
<font color='#0000FF'>#include</font> "<a style='text-decoration:none' href='../byte_orderer.h.html'>../byte_orderer.h</a>"
<font color='#0000FF'>#include</font> "<a style='text-decoration:none' href='../uintn.h.html'>../uintn.h</a>"
<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
<font color='#0000FF'>namespace</font> dlib
<b>{</b>
<font color='#0000FF'><u>void</u></font> <b><a name='load_mnist_dataset'></a>load_mnist_dataset</b> <font face='Lucida Console'>(</font>
<font color='#0000FF'>const</font> std::string<font color='#5555FF'>&amp;</font> folder_name,
std::vector<font color='#5555FF'>&lt;</font>matrix<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>char</u></font><font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> training_images,
std::vector<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font><font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> training_labels,
std::vector<font color='#5555FF'>&lt;</font>matrix<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>char</u></font><font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> testing_images,
std::vector<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font><font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> testing_labels
<font face='Lucida Console'>)</font>
<b>{</b>
<font color='#0000FF'>using</font> <font color='#0000FF'>namespace</font> std;
ifstream <font color='#BB00BB'>fin1</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font>folder_name<font color='#5555FF'>+</font>"<font color='#CC0000'>/train-images-idx3-ubyte</font>"<font face='Lucida Console'>)</font>.<font color='#BB00BB'>c_str</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>, ios::binary<font face='Lucida Console'>)</font>;
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font><font color='#5555FF'>!</font>fin1<font face='Lucida Console'>)</font>
<b>{</b>
fin1.<font color='#BB00BB'>open</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font>folder_name <font color='#5555FF'>+</font> "<font color='#CC0000'>/train-images.idx3-ubyte</font>"<font face='Lucida Console'>)</font>.<font color='#BB00BB'>c_str</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>, ios::binary<font face='Lucida Console'>)</font>;
<b>}</b>
ifstream <font color='#BB00BB'>fin2</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font>folder_name<font color='#5555FF'>+</font>"<font color='#CC0000'>/train-labels-idx1-ubyte</font>"<font face='Lucida Console'>)</font>.<font color='#BB00BB'>c_str</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>, ios::binary<font face='Lucida Console'>)</font>;
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font><font color='#5555FF'>!</font>fin2<font face='Lucida Console'>)</font>
<b>{</b>
fin2.<font color='#BB00BB'>open</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font>folder_name <font color='#5555FF'>+</font> "<font color='#CC0000'>/train-labels.idx1-ubyte</font>"<font face='Lucida Console'>)</font>.<font color='#BB00BB'>c_str</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>, ios::binary<font face='Lucida Console'>)</font>;
<b>}</b>
ifstream <font color='#BB00BB'>fin3</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font>folder_name<font color='#5555FF'>+</font>"<font color='#CC0000'>/t10k-images-idx3-ubyte</font>"<font face='Lucida Console'>)</font>.<font color='#BB00BB'>c_str</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>, ios::binary<font face='Lucida Console'>)</font>;
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font><font color='#5555FF'>!</font>fin3<font face='Lucida Console'>)</font>
<b>{</b>
fin3.<font color='#BB00BB'>open</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font>folder_name <font color='#5555FF'>+</font> "<font color='#CC0000'>/t10k-images.idx3-ubyte</font>"<font face='Lucida Console'>)</font>.<font color='#BB00BB'>c_str</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>, ios::binary<font face='Lucida Console'>)</font>;
<b>}</b>
ifstream <font color='#BB00BB'>fin4</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font>folder_name<font color='#5555FF'>+</font>"<font color='#CC0000'>/t10k-labels-idx1-ubyte</font>"<font face='Lucida Console'>)</font>.<font color='#BB00BB'>c_str</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>, ios::binary<font face='Lucida Console'>)</font>;
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font><font color='#5555FF'>!</font>fin4<font face='Lucida Console'>)</font>
<b>{</b>
fin4.<font color='#BB00BB'>open</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font>folder_name <font color='#5555FF'>+</font> "<font color='#CC0000'>/t10k-labels.idx1-ubyte</font>"<font face='Lucida Console'>)</font>.<font color='#BB00BB'>c_str</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>, ios::binary<font face='Lucida Console'>)</font>;
<b>}</b>
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font><font color='#5555FF'>!</font>fin1<font face='Lucida Console'>)</font> <font color='#0000FF'>throw</font> <font color='#BB00BB'>error</font><font face='Lucida Console'>(</font>"<font color='#CC0000'>Unable to open file train-images-idx3-ubyte or train-images.idx3-ubyte</font>"<font face='Lucida Console'>)</font>;
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font><font color='#5555FF'>!</font>fin2<font face='Lucida Console'>)</font> <font color='#0000FF'>throw</font> <font color='#BB00BB'>error</font><font face='Lucida Console'>(</font>"<font color='#CC0000'>Unable to open file train-labels-idx1-ubyte or train-labels.idx1-ubyte</font>"<font face='Lucida Console'>)</font>;
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font><font color='#5555FF'>!</font>fin3<font face='Lucida Console'>)</font> <font color='#0000FF'>throw</font> <font color='#BB00BB'>error</font><font face='Lucida Console'>(</font>"<font color='#CC0000'>Unable to open file t10k-images-idx3-ubyte or t10k-images.idx3-ubyte</font>"<font face='Lucida Console'>)</font>;
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font><font color='#5555FF'>!</font>fin4<font face='Lucida Console'>)</font> <font color='#0000FF'>throw</font> <font color='#BB00BB'>error</font><font face='Lucida Console'>(</font>"<font color='#CC0000'>Unable to open file t10k-labels-idx1-ubyte or t10k-labels.idx1-ubyte</font>"<font face='Lucida Console'>)</font>;
byte_orderer bo;
<font color='#009900'>// make sure the files have the contents we expect.
</font> uint32 magic, num, nr, nc, num2, num3, num4;
fin1.<font color='#BB00BB'>read</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#0000FF'><u>char</u></font><font color='#5555FF'>*</font><font face='Lucida Console'>)</font><font color='#5555FF'>&amp;</font>magic, <font color='#0000FF'>sizeof</font><font face='Lucida Console'>(</font>magic<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>; bo.<font color='#BB00BB'>big_to_host</font><font face='Lucida Console'>(</font>magic<font face='Lucida Console'>)</font>;
fin1.<font color='#BB00BB'>read</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#0000FF'><u>char</u></font><font color='#5555FF'>*</font><font face='Lucida Console'>)</font><font color='#5555FF'>&amp;</font>num, <font color='#0000FF'>sizeof</font><font face='Lucida Console'>(</font>num<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>; bo.<font color='#BB00BB'>big_to_host</font><font face='Lucida Console'>(</font>num<font face='Lucida Console'>)</font>;
fin1.<font color='#BB00BB'>read</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#0000FF'><u>char</u></font><font color='#5555FF'>*</font><font face='Lucida Console'>)</font><font color='#5555FF'>&amp;</font>nr, <font color='#0000FF'>sizeof</font><font face='Lucida Console'>(</font>nr<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>; bo.<font color='#BB00BB'>big_to_host</font><font face='Lucida Console'>(</font>nr<font face='Lucida Console'>)</font>;
fin1.<font color='#BB00BB'>read</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#0000FF'><u>char</u></font><font color='#5555FF'>*</font><font face='Lucida Console'>)</font><font color='#5555FF'>&amp;</font>nc, <font color='#0000FF'>sizeof</font><font face='Lucida Console'>(</font>nc<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>; bo.<font color='#BB00BB'>big_to_host</font><font face='Lucida Console'>(</font>nc<font face='Lucida Console'>)</font>;
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>magic <font color='#5555FF'>!</font><font color='#5555FF'>=</font> <font color='#979000'>2051</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> num <font color='#5555FF'>!</font><font color='#5555FF'>=</font> <font color='#979000'>60000</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> nr <font color='#5555FF'>!</font><font color='#5555FF'>=</font> <font color='#979000'>28</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> nc <font color='#5555FF'>!</font><font color='#5555FF'>=</font> <font color='#979000'>28</font><font face='Lucida Console'>)</font>
<font color='#0000FF'>throw</font> <font color='#BB00BB'>error</font><font face='Lucida Console'>(</font>"<font color='#CC0000'>mnist dat files are corrupted.</font>"<font face='Lucida Console'>)</font>;
fin2.<font color='#BB00BB'>read</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#0000FF'><u>char</u></font><font color='#5555FF'>*</font><font face='Lucida Console'>)</font><font color='#5555FF'>&amp;</font>magic, <font color='#0000FF'>sizeof</font><font face='Lucida Console'>(</font>magic<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>; bo.<font color='#BB00BB'>big_to_host</font><font face='Lucida Console'>(</font>magic<font face='Lucida Console'>)</font>;
fin2.<font color='#BB00BB'>read</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#0000FF'><u>char</u></font><font color='#5555FF'>*</font><font face='Lucida Console'>)</font><font color='#5555FF'>&amp;</font>num2, <font color='#0000FF'>sizeof</font><font face='Lucida Console'>(</font>num2<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>; bo.<font color='#BB00BB'>big_to_host</font><font face='Lucida Console'>(</font>num2<font face='Lucida Console'>)</font>;
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>magic <font color='#5555FF'>!</font><font color='#5555FF'>=</font> <font color='#979000'>2049</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> num2 <font color='#5555FF'>!</font><font color='#5555FF'>=</font> <font color='#979000'>60000</font><font face='Lucida Console'>)</font>
<font color='#0000FF'>throw</font> <font color='#BB00BB'>error</font><font face='Lucida Console'>(</font>"<font color='#CC0000'>mnist dat files are corrupted.</font>"<font face='Lucida Console'>)</font>;
fin3.<font color='#BB00BB'>read</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#0000FF'><u>char</u></font><font color='#5555FF'>*</font><font face='Lucida Console'>)</font><font color='#5555FF'>&amp;</font>magic, <font color='#0000FF'>sizeof</font><font face='Lucida Console'>(</font>magic<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>; bo.<font color='#BB00BB'>big_to_host</font><font face='Lucida Console'>(</font>magic<font face='Lucida Console'>)</font>;
fin3.<font color='#BB00BB'>read</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#0000FF'><u>char</u></font><font color='#5555FF'>*</font><font face='Lucida Console'>)</font><font color='#5555FF'>&amp;</font>num3, <font color='#0000FF'>sizeof</font><font face='Lucida Console'>(</font>num3<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>; bo.<font color='#BB00BB'>big_to_host</font><font face='Lucida Console'>(</font>num3<font face='Lucida Console'>)</font>;
fin3.<font color='#BB00BB'>read</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#0000FF'><u>char</u></font><font color='#5555FF'>*</font><font face='Lucida Console'>)</font><font color='#5555FF'>&amp;</font>nr, <font color='#0000FF'>sizeof</font><font face='Lucida Console'>(</font>nr<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>; bo.<font color='#BB00BB'>big_to_host</font><font face='Lucida Console'>(</font>nr<font face='Lucida Console'>)</font>;
fin3.<font color='#BB00BB'>read</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#0000FF'><u>char</u></font><font color='#5555FF'>*</font><font face='Lucida Console'>)</font><font color='#5555FF'>&amp;</font>nc, <font color='#0000FF'>sizeof</font><font face='Lucida Console'>(</font>nc<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>; bo.<font color='#BB00BB'>big_to_host</font><font face='Lucida Console'>(</font>nc<font face='Lucida Console'>)</font>;
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>magic <font color='#5555FF'>!</font><font color='#5555FF'>=</font> <font color='#979000'>2051</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> num3 <font color='#5555FF'>!</font><font color='#5555FF'>=</font> <font color='#979000'>10000</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> nr <font color='#5555FF'>!</font><font color='#5555FF'>=</font> <font color='#979000'>28</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> nc <font color='#5555FF'>!</font><font color='#5555FF'>=</font> <font color='#979000'>28</font><font face='Lucida Console'>)</font>
<font color='#0000FF'>throw</font> <font color='#BB00BB'>error</font><font face='Lucida Console'>(</font>"<font color='#CC0000'>mnist dat files are corrupted.</font>"<font face='Lucida Console'>)</font>;
fin4.<font color='#BB00BB'>read</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#0000FF'><u>char</u></font><font color='#5555FF'>*</font><font face='Lucida Console'>)</font><font color='#5555FF'>&amp;</font>magic, <font color='#0000FF'>sizeof</font><font face='Lucida Console'>(</font>magic<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>; bo.<font color='#BB00BB'>big_to_host</font><font face='Lucida Console'>(</font>magic<font face='Lucida Console'>)</font>;
fin4.<font color='#BB00BB'>read</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#0000FF'><u>char</u></font><font color='#5555FF'>*</font><font face='Lucida Console'>)</font><font color='#5555FF'>&amp;</font>num4, <font color='#0000FF'>sizeof</font><font face='Lucida Console'>(</font>num4<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>; bo.<font color='#BB00BB'>big_to_host</font><font face='Lucida Console'>(</font>num4<font face='Lucida Console'>)</font>;
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>magic <font color='#5555FF'>!</font><font color='#5555FF'>=</font> <font color='#979000'>2049</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> num4 <font color='#5555FF'>!</font><font color='#5555FF'>=</font> <font color='#979000'>10000</font><font face='Lucida Console'>)</font>
<font color='#0000FF'>throw</font> <font color='#BB00BB'>error</font><font face='Lucida Console'>(</font>"<font color='#CC0000'>mnist dat files are corrupted.</font>"<font face='Lucida Console'>)</font>;
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font><font color='#5555FF'>!</font>fin1<font face='Lucida Console'>)</font> <font color='#0000FF'>throw</font> <font color='#BB00BB'>error</font><font face='Lucida Console'>(</font>"<font color='#CC0000'>Unable to read train-images-idx3-ubyte</font>"<font face='Lucida Console'>)</font>;
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font><font color='#5555FF'>!</font>fin2<font face='Lucida Console'>)</font> <font color='#0000FF'>throw</font> <font color='#BB00BB'>error</font><font face='Lucida Console'>(</font>"<font color='#CC0000'>Unable to read train-labels-idx1-ubyte</font>"<font face='Lucida Console'>)</font>;
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font><font color='#5555FF'>!</font>fin3<font face='Lucida Console'>)</font> <font color='#0000FF'>throw</font> <font color='#BB00BB'>error</font><font face='Lucida Console'>(</font>"<font color='#CC0000'>Unable to read t10k-images-idx3-ubyte</font>"<font face='Lucida Console'>)</font>;
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font><font color='#5555FF'>!</font>fin4<font face='Lucida Console'>)</font> <font color='#0000FF'>throw</font> <font color='#BB00BB'>error</font><font face='Lucida Console'>(</font>"<font color='#CC0000'>Unable to read t10k-labels-idx1-ubyte</font>"<font face='Lucida Console'>)</font>;
training_images.<font color='#BB00BB'>resize</font><font face='Lucida Console'>(</font><font color='#979000'>60000</font><font face='Lucida Console'>)</font>;
training_labels.<font color='#BB00BB'>resize</font><font face='Lucida Console'>(</font><font color='#979000'>60000</font><font face='Lucida Console'>)</font>;
testing_images.<font color='#BB00BB'>resize</font><font face='Lucida Console'>(</font><font color='#979000'>10000</font><font face='Lucida Console'>)</font>;
testing_labels.<font color='#BB00BB'>resize</font><font face='Lucida Console'>(</font><font color='#979000'>10000</font><font face='Lucida Console'>)</font>;
<font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>size_t</u></font> i <font color='#5555FF'>=</font> <font color='#979000'>0</font>; i <font color='#5555FF'>&lt;</font> training_images.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>i<font face='Lucida Console'>)</font>
<b>{</b>
training_images[i].<font color='#BB00BB'>set_size</font><font face='Lucida Console'>(</font>nr,nc<font face='Lucida Console'>)</font>;
fin1.<font color='#BB00BB'>read</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#0000FF'><u>char</u></font><font color='#5555FF'>*</font><font face='Lucida Console'>)</font><font color='#5555FF'>&amp;</font>training_images[i]<font face='Lucida Console'>(</font><font color='#979000'>0</font>,<font color='#979000'>0</font><font face='Lucida Console'>)</font>, nr<font color='#5555FF'>*</font>nc<font face='Lucida Console'>)</font>;
<b>}</b>
<font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>size_t</u></font> i <font color='#5555FF'>=</font> <font color='#979000'>0</font>; i <font color='#5555FF'>&lt;</font> training_labels.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>i<font face='Lucida Console'>)</font>
<b>{</b>
<font color='#0000FF'><u>char</u></font> l;
fin2.<font color='#BB00BB'>read</font><font face='Lucida Console'>(</font><font color='#5555FF'>&amp;</font>l, <font color='#979000'>1</font><font face='Lucida Console'>)</font>;
training_labels[i] <font color='#5555FF'>=</font> l;
<b>}</b>
<font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>size_t</u></font> i <font color='#5555FF'>=</font> <font color='#979000'>0</font>; i <font color='#5555FF'>&lt;</font> testing_images.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>i<font face='Lucida Console'>)</font>
<b>{</b>
testing_images[i].<font color='#BB00BB'>set_size</font><font face='Lucida Console'>(</font>nr,nc<font face='Lucida Console'>)</font>;
fin3.<font color='#BB00BB'>read</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#0000FF'><u>char</u></font><font color='#5555FF'>*</font><font face='Lucida Console'>)</font><font color='#5555FF'>&amp;</font>testing_images[i]<font face='Lucida Console'>(</font><font color='#979000'>0</font>,<font color='#979000'>0</font><font face='Lucida Console'>)</font>, nr<font color='#5555FF'>*</font>nc<font face='Lucida Console'>)</font>;
<b>}</b>
<font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>size_t</u></font> i <font color='#5555FF'>=</font> <font color='#979000'>0</font>; i <font color='#5555FF'>&lt;</font> testing_labels.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>i<font face='Lucida Console'>)</font>
<b>{</b>
<font color='#0000FF'><u>char</u></font> l;
fin4.<font color='#BB00BB'>read</font><font face='Lucida Console'>(</font><font color='#5555FF'>&amp;</font>l, <font color='#979000'>1</font><font face='Lucida Console'>)</font>;
testing_labels[i] <font color='#5555FF'>=</font> l;
<b>}</b>
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font><font color='#5555FF'>!</font>fin1<font face='Lucida Console'>)</font> <font color='#0000FF'>throw</font> <font color='#BB00BB'>error</font><font face='Lucida Console'>(</font>"<font color='#CC0000'>Unable to read train-images-idx3-ubyte</font>"<font face='Lucida Console'>)</font>;
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font><font color='#5555FF'>!</font>fin2<font face='Lucida Console'>)</font> <font color='#0000FF'>throw</font> <font color='#BB00BB'>error</font><font face='Lucida Console'>(</font>"<font color='#CC0000'>Unable to read train-labels-idx1-ubyte</font>"<font face='Lucida Console'>)</font>;
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font><font color='#5555FF'>!</font>fin3<font face='Lucida Console'>)</font> <font color='#0000FF'>throw</font> <font color='#BB00BB'>error</font><font face='Lucida Console'>(</font>"<font color='#CC0000'>Unable to read t10k-images-idx3-ubyte</font>"<font face='Lucida Console'>)</font>;
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font><font color='#5555FF'>!</font>fin4<font face='Lucida Console'>)</font> <font color='#0000FF'>throw</font> <font color='#BB00BB'>error</font><font face='Lucida Console'>(</font>"<font color='#CC0000'>Unable to read t10k-labels-idx1-ubyte</font>"<font face='Lucida Console'>)</font>;
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>fin1.<font color='#BB00BB'>get</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>!</font><font color='#5555FF'>=</font> EOF<font face='Lucida Console'>)</font> <font color='#0000FF'>throw</font> <font color='#BB00BB'>error</font><font face='Lucida Console'>(</font>"<font color='#CC0000'>Unexpected bytes at end of train-images-idx3-ubyte</font>"<font face='Lucida Console'>)</font>;
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>fin2.<font color='#BB00BB'>get</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>!</font><font color='#5555FF'>=</font> EOF<font face='Lucida Console'>)</font> <font color='#0000FF'>throw</font> <font color='#BB00BB'>error</font><font face='Lucida Console'>(</font>"<font color='#CC0000'>Unexpected bytes at end of train-labels-idx1-ubyte</font>"<font face='Lucida Console'>)</font>;
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>fin3.<font color='#BB00BB'>get</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>!</font><font color='#5555FF'>=</font> EOF<font face='Lucida Console'>)</font> <font color='#0000FF'>throw</font> <font color='#BB00BB'>error</font><font face='Lucida Console'>(</font>"<font color='#CC0000'>Unexpected bytes at end of t10k-images-idx3-ubyte</font>"<font face='Lucida Console'>)</font>;
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>fin4.<font color='#BB00BB'>get</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>!</font><font color='#5555FF'>=</font> EOF<font face='Lucida Console'>)</font> <font color='#0000FF'>throw</font> <font color='#BB00BB'>error</font><font face='Lucida Console'>(</font>"<font color='#CC0000'>Unexpected bytes at end of t10k-labels-idx1-ubyte</font>"<font face='Lucida Console'>)</font>;
<b>}</b>
<b>}</b>
<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
<font color='#0000FF'>#endif</font> <font color='#009900'>// DLIB_MNIST_CPp_
</font>
</pre></body></html>