General
DaNNet is a C++ Deep Artificial Neural Network processing library/framework using the Armadillo library as a base.
Features
- Easy to use, based on Armadillo library
- Layers: Input, Dense, Convolution, Pool, Batch norm, Dropout, Cost
- Activations: Sigmoid, tanh, ReLU, LReLU, softplus, softmax
- Layer-wise optimizations
- Regularization: LASSO, ridge, elastic net
- Optimizers: SGD, Nesterov, ADAM, RMSprop, ADAdelta, ADAgrad, ADAmax
- MNIST import support
Installation
Download DaNNet and install/extract it to your install directory of choice.
After extracting you should have a directory structure as:
└── DaNNet
├── data
├── doc
├── examples
└── include
Download and install Armadillo, version >= 8.4 is used in the examples.
Linux
sudo apt install libarmadillo-dev
Windows
See https://gitlab.com/conradsnicta/armadillo-code/blob/9.300.x/README.md#7-windows-installation
Linux build example
> cd examples
> g++ -O3 Spiral.cpp -I../include -larmadillo -o Spiral
> ./Spiral
...or
> cd examples
> make Spiral
> ./Spiral
Code examples
Spiral.cpp:
int main()
{
std::cout << "Compile time : " << __TIME__ << " at " << __DATE__ << std::endl;
std::cout << "Armadillo version: " << arma::arma_version::as_string() << std::endl;
std::cout <<
"DaNNet version : " <<
version_info() << std::endl;
arma::arma_rng::set_seed_random();
arma::Mat<DNN_Dtype> X,T;
arma::uword N = 30000, Ntest = 1000, K = 3;
arma::uword Nepoch = 20;
arma::uword Nbatch = 32;
arma::Mat<DNN_Dtype> Xtrain = X;
arma::Mat<DNN_Dtype> Ttrain = T;
d1.set_opt_alg(alg1);
d2.set_opt_alg(alg2);
d3.set_opt_alg(alg3);
{
std::cout << "\nModel successfully validated!" << std::endl;
}
model.
data_set(Xtrain, Ttrain,Nbatch,Nepoch);
for (arma::uword n = 0; n < Nepoch; n++)
{
}
arma::Mat<DNN_Dtype> Xtest,Ttest;
return 0;
}
MNIST.cpp: (Download MNIST dataset to ../data first)
int main()
{
std::cout << "Compile time : " << __TIME__ << " at " << __DATE__ << std::endl;
std::cout << "Armadillo version: " << arma::arma_version::as_string() << std::endl;
std::cout <<
"DaNNet version : " <<
version_info() << std::endl;
arma::Mat<DNN_Dtype> Xtrain,Ttrain;
read_MNIST(
"../data/train-images.idx3-ubyte",
"../data/train-labels.idx1-ubyte",Xtrain,Ttrain,1);
c1.set_opt_alg(alg1);
c2.set_opt_alg(alg2);
d1.set_opt_alg(alg3);
d2.set_opt_alg(alg4);
d3.set_opt_alg(alg5);
arma::uword Nbatch=64;
arma::uword Nepoch=5;
{
std::cout << "\nModel successfully validated!" << std::endl;
}
model.
data_set(Xtrain, Ttrain,Nbatch,Nepoch);
for (arma::uword n = 0; n < Nepoch; n++)
{
}
arma::Mat<DNN_Dtype> Xtest,Ttest;
read_MNIST(
"../data/t10k-images.idx3-ubyte",
"../data/t10k-labels.idx1-ubyte",Xtest,Ttest,1);
return 0;
}