mlpack::data Namespace Reference
Functions to load and save matrices. More...
Functions | |
| template<typename eT > | |
| bool | Load (const std::string &filename, arma::Mat< eT > &matrix, bool fatal=false, bool transpose=true) |
| Loads a matrix from file, guessing the filetype from the extension. | |
| template<typename eT > | |
| bool | Save (const std::string &filename, const arma::Mat< eT > &matrix, bool fatal=false, bool transpose=true) |
| Saves a matrix to file, guessing the filetype from the extension. | |
Detailed Description
Functions to load and save matrices.
Function Documentation
| bool mlpack::data::Load | ( | const std::string & | filename, | |
| arma::Mat< eT > & | matrix, | |||
| bool | fatal = false, |
|||
| bool | transpose = true | |||
| ) |
Loads a matrix from file, guessing the filetype from the extension.
This will transpose the matrix at load time. If the filetype cannot be determined, an error will be given.
The supported types of files are the same as found in Armadillo:
- CSV (csv_ascii), denoted by .csv, or optionally .txt
- ASCII (raw_ascii), denoted by .txt
- Armadillo ASCII (arma_ascii), also denoted by .txt
- PGM (pgm_binary), denoted by .pgm
- PPM (ppm_binary), denoted by .ppm
- Raw binary (raw_binary), denoted by .bin
- Armadillo binary (arma_binary), denoted by .bin
- HDF5, denoted by .hdf, .hdf5, .h5, or .he5
If the file extension is not one of those types, an error will be given. This is preferable to Armadillo's default behavior of loading an unknown filetype as raw_binary, which can have very confusing effects.
If the parameter 'fatal' is set to true, the program will exit with an error if the matrix does not load successfully. The parameter 'transpose' controls whether or not the matrix is transposed after loading. In most cases, because data is generally stored in a row-major format and mlpack requires column-major matrices, this should be left at its default value of 'true'.
- Parameters:
-
filename Name of file to load. matrix Matrix to load contents of file into. fatal If an error should be reported as fatal (default false). transpose If true, transpose the matrix after loading.
- Returns:
- Boolean value indicating success or failure of load.
| bool mlpack::data::Save | ( | const std::string & | filename, | |
| const arma::Mat< eT > & | matrix, | |||
| bool | fatal = false, |
|||
| bool | transpose = true | |||
| ) |
Saves a matrix to file, guessing the filetype from the extension.
This will transpose the matrix at save time. If the filetype cannot be determined, an error will be given.
The supported types of files are the same as found in Armadillo:
- CSV (csv_ascii), denoted by .csv, or optionally .txt
- ASCII (raw_ascii), denoted by .txt
- Armadillo ASCII (arma_ascii), also denoted by .txt
- PGM (pgm_binary), denoted by .pgm
- PPM (ppm_binary), denoted by .ppm
- Raw binary (raw_binary), denoted by .bin
- Armadillo binary (arma_binary), denoted by .bin
- HDF5 (hdf5_binary), denoted by .hdf5, .hdf, .h5, or .he5
If the file extension is not one of those types, an error will be given. If the 'fatal' parameter is set to true, an error will cause the program to exit. If the 'transpose' parameter is set to true, the matrix will be transposed before saving. Generally, because mlpack stores matrices in a column-major format and most datasets are stored on disk as row-major, this parameter should be left at its default value of 'true'.
- Parameters:
-
filename Name of file to save to. matrix Matrix to save into file. fatal If an error should be reported as fatal (default false). transpose If true, transpose the matrix before saving.
- Returns:
- Boolean value indicating success or failure of save.
Generated on Thu May 2 2013 01:04:29 for mlpack by
1.7.1
