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 
62 template<typename eT>
63 bool Load(const std::string& filename,
64  arma::Mat<eT>& matrix,
65  const bool fatal = false,
66  const bool transpose = true);
67 
97 template<typename eT>
98 bool Load(const std::string& filename,
99  arma::SpMat<eT>& matrix,
100  const bool fatal = false,
101  const bool transpose = true);
102 
110 extern template bool Load<int>(const std::string&,
111  arma::Mat<int>&,
112  const bool,
113  const bool);
114 
115 // size_t and uword should be one of these three typedefs.
116 extern template bool Load<unsigned int>(const std::string&,
117  arma::Mat<unsigned int>&,
118  const bool,
119  const bool);
120 
121 extern template bool Load<unsigned long>(const std::string&,
122  arma::Mat<unsigned long>&,
123  const bool,
124  const bool);
125 
126 extern template bool Load<unsigned long long>(const std::string&,
127  arma::Mat<unsigned long long>&,
128  const bool,
129  const bool);
130 
131 extern template bool Load<float>(const std::string&,
132  arma::Mat<float>&,
133  const bool,
134  const bool);
135 
136 extern template bool Load<double>(const std::string&,
137  arma::Mat<double>&,
138  const bool,
139  const bool);
140 
141 extern template bool Load<int>(const std::string&,
142  arma::Mat<int>&,
143  const bool,
144  const bool);
145 
146 extern template bool Load<unsigned int>(const std::string&,
147  arma::SpMat<unsigned int>&,
148  const bool,
149  const bool);
150 
151 extern template bool Load<unsigned long>(const std::string&,
152  arma::SpMat<unsigned long>&,
153  const bool,
154  const bool);
155 
156 extern template bool Load<unsigned long long>(const std::string&,
157  arma::SpMat<unsigned long long>&,
158  const bool,
159  const bool);
160 
161 extern template bool Load<float>(const std::string&,
162  arma::SpMat<float>&,
163  const bool,
164  const bool);
165 
166 extern template bool Load<double>(const std::string&,
167  arma::SpMat<double>&,
168  const bool,
169  const bool);
170 
202 template<typename eT>
203 bool Load(const std::string& filename,
204  arma::Col<eT>& vec,
205  const bool fatal = false);
206 
234 template<typename eT>
235 bool Load(const std::string& filename,
236  arma::Row<eT>& rowvec,
237  const bool fatal = false);
238 
271 template<typename eT, typename PolicyType>
272 bool Load(const std::string& filename,
273  arma::Mat<eT>& matrix,
274  DatasetMapper<PolicyType>& info,
275  const bool fatal = false,
276  const bool transpose = true);
277 
285 extern template bool Load<int, IncrementPolicy>(
286  const std::string&,
287  arma::Mat<int>&,
288  DatasetMapper<IncrementPolicy>&,
289  const bool,
290  const bool);
291 
292 extern template bool Load<arma::u32, IncrementPolicy>(
293  const std::string&,
294  arma::Mat<arma::u32>&,
295  DatasetMapper<IncrementPolicy>&,
296  const bool,
297  const bool);
298 
299 extern template bool Load<arma::u64, IncrementPolicy>(
300  const std::string&,
301  arma::Mat<arma::u64>&,
302  DatasetMapper<IncrementPolicy>&,
303  const bool,
304  const bool);
305 
306 extern template bool Load<float, IncrementPolicy>(
307  const std::string&,
308  arma::Mat<float>&,
309  DatasetMapper<IncrementPolicy>&,
310  const bool,
311  const bool);
312 
313 extern template bool Load<double, IncrementPolicy>(
314  const std::string&,
315  arma::Mat<double>&,
316  DatasetMapper<IncrementPolicy>&,
317  const bool,
318  const bool);
319 
349 template<typename T>
350 bool Load(const std::string& filename,
351  const std::string& name,
352  T& t,
353  const bool fatal = false,
355 
369 template<typename eT>
370 bool Load(const std::string& filename,
371  arma::Mat<eT>& matrix,
372  ImageInfo& info,
373  const bool fatal = false);
374 
384 template<typename eT>
385 bool Load(const std::vector<std::string>& files,
386  arma::Mat<eT>& matrix,
387  ImageInfo& info,
388  const bool fatal = false);
389 
390 // Implementation found in load_image.cpp.
391 bool LoadImage(const std::string& filename,
392  arma::Mat<unsigned char>& matrix,
393  ImageInfo& info,
394  const bool fatal = false);
395 
396 } // namespace data
397 } // namespace mlpack
398 
399 // Include implementation of model-loading Load() overload.
400 #include "load_model_impl.hpp"
401 // Include implementation of Load() for vectors.
402 #include "load_vec_impl.hpp"
403 // Include implementation of Load() for images.
404 #include "load_image_impl.hpp"
405 
406 #endif
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: add_to_po.hpp:21
format
Define the formats we can read through boost::serialization.
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)
Loads a matrix from file, guessing the filetype from the extension.