DaNNet
|
Miscellaneous functions. More...
Functions | |
std::string | dnn::version_info (void) |
Generate DaNNet version string. More... | |
template<typename T > | |
void | dnn::pol2cart (const T phi, const T r, T &x, T &y) |
Polar to cartesian convertion. More... | |
template<typename T > | |
void | dnn::pol2cart (const arma::Mat< T > phi, const arma::Mat< T > r, arma::Mat< T > &x, arma::Mat< T > &y) |
Polar to cartesian convertion (matrix) More... | |
template<typename T > | |
void | dnn::cart2pol (const T x, const T y, T &phi, T &r) |
Cartesian to polar convertion. More... | |
template<typename T > | |
void | dnn::cart2pol (const arma::Mat< T > x, const arma::Mat< T > y, arma::Mat< T > &phi, arma::Mat< T > &r) |
Cartesian to polar convertion (matrix) More... | |
arma_inline arma::Mat< DNN_Dtype > | dnn::row2col (const arma::Mat< DNN_Dtype > &A) |
Flattens a matrix row-wise to a one column matrix. More... | |
arma_inline arma::Mat< DNN_Dtype > | dnn::col2col (const arma::Mat< DNN_Dtype > &A) |
Flattens a matrix col-wise to a one column matrix. More... | |
arma_inline arma::Mat< DNN_Dtype > | dnn::mat2mat (const arma::Mat< DNN_Dtype > &A, const arma::uword rows, const arma::uword cols) |
Reshapes a matrix. More... | |
arma_inline arma::Cube< DNN_Dtype > | dnn::mat2cube (const arma::Mat< DNN_Dtype > &A, const arma::uword rows, const arma::uword cols, const arma::uword slices) |
Converts a matrix to a cube. More... | |
arma_inline arma::Mat< DNN_Dtype > | dnn::cube2mat (arma::Cube< DNN_Dtype > &A, const arma::uword rows, const arma::uword cols) |
Converts a cube to a matrix. More... | |
void | dnn::gen_spiral (arma::Mat< DNN_Dtype > &X, arma::Mat< DNN_Dtype > &T, arma::uword N, arma::uword K, const double ph_var=0.1, const double r_min=0.1, const double ph_max=7) |
Dataset generator: a rotating spiral with K classes. More... | |
uint32_t | dnn::swap_endian (uint32_t i) |
Endian converter for IDX1 and IDX3 file. More... | |
bool | dnn::read_idx3 (std::string fname, arma::Cube< DNN_Dtype > &img, const double frac=1.0) |
Reads a IDX3 file. More... | |
bool | dnn::read_idx1 (std::string fname, arma::ivec &label, const double frac=1.0) |
Reads a IDX1 file. More... | |
void | dnn::read_MNIST (std::string fname_X, std::string fname_T, arma::Mat< DNN_Dtype > &X, arma::Mat< DNN_Dtype > &T, double frac=1.0) |
Reads a MNIST digit dataset. More... | |
void | dnn::progress_bar (const std::string str, double p) |
Console progress bar. More... | |
void | dnn::progress_bar (const std::string str, arma::uword num, arma::uword maxnum) |
Console progress bar. More... | |
void | dnn::remove_progress_bar (void) |
Clears progress bar. More... | |
Miscellaneous functions.
void dnn::cart2pol | ( | const T | x, |
const T | y, | ||
T & | phi, | ||
T & | r | ||
) |
Cartesian to polar convertion.
[in] | x,y | Cartesian coordiate |
[out] | phi,r | Angle (in radians) and radius |
Converts between cartesian and polar format
Definition at line 69 of file dnn_misc.h.
void dnn::cart2pol | ( | const arma::Mat< T > | x, |
const arma::Mat< T > | y, | ||
arma::Mat< T > & | phi, | ||
arma::Mat< T > & | r | ||
) |
Cartesian to polar convertion (matrix)
[in] | x,y | Cartesian coordiate |
[out] | phi,r | Angle (in radians) and radius |
Converts between cartesian and polar format for matrix data
Definition at line 83 of file dnn_misc.h.
Flattens a matrix col-wise to a one column matrix.
[in] | A | Input matrix [M,N] |
Concatenates cols in the matrix A[M,N] to A[M*N,1]
Definition at line 110 of file dnn_misc.h.
arma_inline arma::Mat<DNN_Dtype> dnn::cube2mat | ( | arma::Cube< DNN_Dtype > & | A, |
const arma::uword | rows, | ||
const arma::uword | cols | ||
) |
Converts a cube to a matrix.
[in] | A | Input cube [M,N,P] |
[in] | rows | Number of rows |
[in] | cols | Number of columns |
Reshapes the cube layer-wise A[M,N,P] to A[M*N*P,1] and then to A[K,L] K*L must be equal to M*N*P
Definition at line 158 of file dnn_misc.h.
void dnn::gen_spiral | ( | arma::Mat< DNN_Dtype > & | X, |
arma::Mat< DNN_Dtype > & | T, | ||
arma::uword | N, | ||
arma::uword | K, | ||
const double | ph_var = 0.1 , |
||
const double | r_min = 0.1 , |
||
const double | ph_max = 7 |
||
) |
Dataset generator: a rotating spiral with K classes.
[in] | N | Number of test samples |
[in] | K | Number of classes (fans) |
[in] | ph_var | Model param, phase variance |
[in] | r_min | Model param, radius start value |
[in] | ph_max | Model param, maximum phase offset |
[out] | X | Matrix with x and y value for each sample, size [2,N] |
[out] | T | Matrix with class category for each sample, size [K,N] |
A 2D dataset for a spiral pattern with K classes is generated
Definition at line 179 of file dnn_misc.h.
arma_inline arma::Cube<DNN_Dtype> dnn::mat2cube | ( | const arma::Mat< DNN_Dtype > & | A, |
const arma::uword | rows, | ||
const arma::uword | cols, | ||
const arma::uword | slices | ||
) |
Converts a matrix to a cube.
[in] | A | Input matrix [K,L] |
[in] | rows | Number of rows |
[in] | cols | Number of columns |
[in] | slices | Number of columns |
Reshapes the matrix col-wise A[K,L] to A[K*L,1] and then to A[M,N,P] K*L must be equal to M*N*P
Definition at line 142 of file dnn_misc.h.
arma_inline arma::Mat<DNN_Dtype> dnn::mat2mat | ( | const arma::Mat< DNN_Dtype > & | A, |
const arma::uword | rows, | ||
const arma::uword | cols | ||
) |
Reshapes a matrix.
[in] | A | Input matrix [K,L] |
[in] | rows | Number of rows |
[in] | cols | Number of columns |
Reshapes the matrix col-wise A[K,L] to A[K*L,1] and then to A[M,N] K*L must be equal to M*N
Definition at line 125 of file dnn_misc.h.
void dnn::pol2cart | ( | const T | phi, |
const T | r, | ||
T & | x, | ||
T & | y | ||
) |
Polar to cartesian convertion.
[in] | phi,r | Angle (in radians) and radius |
[out] | x,y | Cartesian coordiate |
Converts between polar and cartesian format
Definition at line 42 of file dnn_misc.h.
void dnn::pol2cart | ( | const arma::Mat< T > | phi, |
const arma::Mat< T > | r, | ||
arma::Mat< T > & | x, | ||
arma::Mat< T > & | y | ||
) |
Polar to cartesian convertion (matrix)
[in] | phi,r | Angle (in radians) and radius |
[out] | x,y | Cartesian coordiate |
Converts between polar and cartesian format for matrix data
Definition at line 55 of file dnn_misc.h.
void dnn::progress_bar | ( | const std::string | str, |
double | p | ||
) |
Console progress bar.
[in] | str | Info string |
[in] | p | Progress quota |
Prints a progress bar at stdout
Definition at line 382 of file dnn_misc.h.
void dnn::progress_bar | ( | const std::string | str, |
arma::uword | num, | ||
arma::uword | maxnum | ||
) |
Console progress bar.
[in] | str | Info string |
[in] | num | Current iteration |
[in] | maxnum | Target (100%) iterations |
Prints a progress bar at stdout
Definition at line 412 of file dnn_misc.h.
bool dnn::read_idx1 | ( | std::string | fname, |
arma::ivec & | label, | ||
const double | frac = 1.0 |
||
) |
Reads a IDX1 file.
[in] | fname | File name |
[in] | frac | Number of images in dataset to read [0..1] |
[out] | label | Labels stored in a vector |
Reads a IDX1 file, as used by MNIST digit dataset See http://yann.lecun.com/exdb/mnist/
Definition at line 305 of file dnn_misc.h.
bool dnn::read_idx3 | ( | std::string | fname, |
arma::Cube< DNN_Dtype > & | img, | ||
const double | frac = 1.0 |
||
) |
Reads a IDX3 file.
[in] | fname | File name |
[in] | frac | Number of images in dataset to read [0..1] |
[out] | img | Images stored in a cube [R,C,N] |
Reads a IDX3 file, as used by MNIST digit dataset See http://yann.lecun.com/exdb/mnist/
Definition at line 246 of file dnn_misc.h.
void dnn::read_MNIST | ( | std::string | fname_X, |
std::string | fname_T, | ||
arma::Mat< DNN_Dtype > & | X, | ||
arma::Mat< DNN_Dtype > & | T, | ||
double | frac = 1.0 |
||
) |
Reads a MNIST digit dataset.
[in] | fname_X | File name of the data |
[in] | fname_T | File name of the label |
[in] | frac | Number of images in dataset to read [0..1] |
[out] | X | Images stored in a matrix [R*C,N] |
[out] | T | Images stored in a matrix [10,N] |
Reads MNIST digit dataset, returns a data matrix scaled to [0..1] and a label matrix one-hot-encoded. Download data from http://yann.lecun.com/exdb/mnist/
Definition at line 352 of file dnn_misc.h.
void dnn::remove_progress_bar | ( | void | ) |
Flattens a matrix row-wise to a one column matrix.
[in] | A | Input matrix [M,N] |
Concatenates rows in the matrix A[M,N] to A[M*N,1]
Definition at line 97 of file dnn_misc.h.
uint32_t dnn::swap_endian | ( | uint32_t | i | ) |
Endian converter for IDX1 and IDX3 file.
Definition at line 226 of file dnn_misc.h.
std::string dnn::version_info | ( | void | ) |