load.hpp
Go to the documentation of this file.
1 
14 #ifndef MLPACK_CORE_DATA_LOAD_HPP
15 #define MLPACK_CORE_DATA_LOAD_HPP
16 
17 #include <mlpack/prereqs.hpp>
18 #include <mlpack/core/util/log.hpp>
19 #include <string>
20 
21 #include "format.hpp"
22 #include "dataset_mapper.hpp"
23 #include "image_info.hpp"
24 
25 namespace mlpack {
26 namespace data {
27 
69 template<typename eT>
70 bool Load(const std::string& filename,
71  arma::Mat<eT>& matrix,
72  const bool fatal = false,
73  const bool transpose = true,
74  const arma::file_type inputLoadType = arma::auto_detect);
75 
105 template<typename eT>
106 bool Load(const std::string& filename,
107  arma::SpMat<eT>& matrix,
108  const bool fatal = false,
109  const bool transpose = true);
110 
118 extern template bool Load<int>(const std::string&,
119  arma::Mat<int>&,
120  const bool,
121  const bool,
122  const arma::file_type);
123 
124 // size_t and uword should be one of these three typedefs.
125 extern template bool Load<unsigned int>(const std::string&,
126  arma::Mat<unsigned int>&,
127  const bool,
128  const bool,
129  const arma::file_type);
130 
131 extern template bool Load<unsigned long>(const std::string&,
132  arma::Mat<unsigned long>&,
133  const bool,
134  const bool,
135  const arma::file_type);
136 
137 extern template bool Load<unsigned long long>(const std::string&,
138  arma::Mat<unsigned long long>&,
139  const bool,
140  const bool,
141  const arma::file_type);
142 
143 extern template bool Load<float>(const std::string&,
144  arma::Mat<float>&,
145  const bool,
146  const bool,
147  const arma::file_type);
148 
149 extern template bool Load<double>(const std::string&,
150  arma::Mat<double>&,
151  const bool,
152  const bool,
153  const arma::file_type);
154 
155 extern template bool Load<int>(const std::string&,
156  arma::Mat<int>&,
157  const bool,
158  const bool,
159  const arma::file_type);
160 
161 extern template bool Load<unsigned int>(const std::string&,
162  arma::SpMat<unsigned int>&,
163  const bool,
164  const bool);
165 
166 extern template bool Load<unsigned long>(const std::string&,
167  arma::SpMat<unsigned long>&,
168  const bool,
169  const bool);
170 
171 extern template bool Load<unsigned long long>(const std::string&,
172  arma::SpMat<unsigned long long>&,
173  const bool,
174  const bool);
175 
176 extern template bool Load<float>(const std::string&,
177  arma::SpMat<float>&,
178  const bool,
179  const bool);
180 
181 extern template bool Load<double>(const std::string&,
182  arma::SpMat<double>&,
183  const bool,
184  const bool);
185 
217 template<typename eT>
218 bool Load(const std::string& filename,
219  arma::Col<eT>& vec,
220  const bool fatal = false);
221 
249 template<typename eT>
250 bool Load(const std::string& filename,
251  arma::Row<eT>& rowvec,
252  const bool fatal = false);
253 
290 template<typename eT, typename PolicyType>
291 bool Load(const std::string& filename,
292  arma::Mat<eT>& matrix,
293  DatasetMapper<PolicyType>& info,
294  const bool fatal = false,
295  const bool transpose = true);
296 
304 extern template bool Load<int, IncrementPolicy>(
305  const std::string&,
306  arma::Mat<int>&,
307  DatasetMapper<IncrementPolicy>&,
308  const bool,
309  const bool);
310 
311 extern template bool Load<arma::u32, IncrementPolicy>(
312  const std::string&,
313  arma::Mat<arma::u32>&,
314  DatasetMapper<IncrementPolicy>&,
315  const bool,
316  const bool);
317 
318 extern template bool Load<arma::u64, IncrementPolicy>(
319  const std::string&,
320  arma::Mat<arma::u64>&,
321  DatasetMapper<IncrementPolicy>&,
322  const bool,
323  const bool);
324 
325 extern template bool Load<float, IncrementPolicy>(
326  const std::string&,
327  arma::Mat<float>&,
328  DatasetMapper<IncrementPolicy>&,
329  const bool,
330  const bool);
331 
332 extern template bool Load<double, IncrementPolicy>(
333  const std::string&,
334  arma::Mat<double>&,
335  DatasetMapper<IncrementPolicy>&,
336  const bool,
337  const bool);
338 
368 template<typename T>
369 bool Load(const std::string& filename,
370  const std::string& name,
371  T& t,
372  const bool fatal = false,
374 
388 template<typename eT>
389 bool Load(const std::string& filename,
390  arma::Mat<eT>& matrix,
391  ImageInfo& info,
392  const bool fatal = false);
393 
403 template<typename eT>
404 bool Load(const std::vector<std::string>& files,
405  arma::Mat<eT>& matrix,
406  ImageInfo& info,
407  const bool fatal = false);
408 
409 // Implementation found in load_image.cpp.
410 bool LoadImage(const std::string& filename,
411  arma::Mat<unsigned char>& matrix,
412  ImageInfo& info,
413  const bool fatal = false);
414 
415 } // namespace data
416 } // namespace mlpack
417 
418 // Include implementation of model-loading Load() overload.
419 #include "load_model_impl.hpp"
420 // Include implementation of Load() for vectors.
421 #include "load_vec_impl.hpp"
422 // Include implementation of Load() for images.
423 #include "load_image_impl.hpp"
424 
425 #endif
Linear algebra utility functions, generally performed on matrices or vectors.
format
Define the formats we can read through cereal.
Definition: format.hpp:20
The core includes that mlpack expects; standard C++ includes and Armadillo.
bool LoadImage(const std::string &filename, arma::Mat< unsigned char > &matrix, ImageInfo &info, const bool fatal=false)
bool Load(const std::string &filename, arma::Mat< eT > &matrix, const bool fatal=false, const bool transpose=true, const arma::file_type inputLoadType=arma::auto_detect)
Loads a matrix from file, guessing the filetype from the extension.