├── .clang-format ├── .color_coded ├── .github └── workflows │ └── make.yml ├── .gitignore ├── .gitmodules ├── .ycm_extra_conf.py ├── AUTHORS ├── ChangeLog.rst ├── Doxyfile ├── Jenkinsfile ├── LICENSE ├── Makefile ├── README.rst ├── compile_commands.json ├── examples └── src │ ├── char_cnn.cpp │ ├── cifar10_cnn.cpp │ ├── imagenet_cnn.cpp │ ├── mnist_ae.cpp │ ├── mnist_cdbn.cpp │ ├── mnist_cnn.cpp │ ├── mnist_dbn.cpp │ ├── mnist_deep_ae.cpp │ ├── mnist_lstm.cpp │ ├── mnist_mlp.cpp │ └── mnist_rnn.cpp ├── include └── dll │ ├── base_conf.hpp │ ├── base_lstm_layer.hpp │ ├── base_rnn_layer.hpp │ ├── base_traits.hpp │ ├── bias_mode.hpp │ ├── contrastive_divergence.hpp │ ├── datasets.hpp │ ├── datasets │ ├── cifar.hpp │ ├── imagenet.hpp │ ├── mnist.hpp │ └── mnist_ae.hpp │ ├── dbn.hpp │ ├── dbn_detail.hpp │ ├── decay_type.hpp │ ├── dll.hpp │ ├── function.hpp │ ├── generators.hpp │ ├── generators │ ├── augmenters.hpp │ ├── cache_helper.hpp │ ├── inmemory_data_generator.hpp │ ├── inmemory_single_data_generator.hpp │ ├── label_cache_helper.hpp │ ├── outmemory_data_generator.hpp │ └── transformers.hpp │ ├── generic_dbn_desc.hpp │ ├── initializer.hpp │ ├── layer.hpp │ ├── layer_fwd.hpp │ ├── layer_traits.hpp │ ├── loss.hpp │ ├── network.hpp │ ├── network_desc.hpp │ ├── network_impl.hpp │ ├── network_layers.hpp │ ├── network_traits.hpp │ ├── neural │ ├── activation │ │ ├── activation_layer.hpp │ │ ├── activation_layer_desc.hpp │ │ └── activation_layer_impl.hpp │ ├── bn │ │ ├── batch_normalization_2d_layer_impl.hpp │ │ ├── batch_normalization_4d_layer_impl.hpp │ │ ├── batch_normalization_layer.hpp │ │ ├── batch_normalization_layer_desc.hpp │ │ ├── dyn_batch_normalization_2d_layer_impl.hpp │ │ └── dyn_batch_normalization_4d_layer_impl.hpp │ ├── conv │ │ ├── conv_layer.hpp │ │ ├── conv_layer_desc.hpp │ │ ├── conv_layer_impl.hpp │ │ ├── conv_same_desc.hpp │ │ ├── conv_same_layer.hpp │ │ ├── conv_same_layer_impl.hpp │ │ ├── deconv_layer.hpp │ │ ├── deconv_layer_desc.hpp │ │ ├── deconv_layer_impl.hpp │ │ ├── dyn_conv_layer.hpp │ │ ├── dyn_conv_layer_desc.hpp │ │ ├── dyn_conv_layer_impl.hpp │ │ ├── dyn_conv_same_desc.hpp │ │ ├── dyn_conv_same_layer.hpp │ │ ├── dyn_conv_same_layer_impl.hpp │ │ ├── dyn_deconv_layer.hpp │ │ ├── dyn_deconv_layer_desc.hpp │ │ └── dyn_deconv_layer_impl.hpp │ ├── dense │ │ ├── dense_layer.hpp │ │ ├── dense_layer_desc.hpp │ │ ├── dense_layer_impl.hpp │ │ ├── dyn_dense_layer.hpp │ │ ├── dyn_dense_layer_desc.hpp │ │ └── dyn_dense_layer_impl.hpp │ ├── dropout │ │ ├── dropout_layer.hpp │ │ ├── dropout_layer_desc.hpp │ │ ├── dropout_layer_impl.hpp │ │ ├── dyn_dropout_layer.hpp │ │ ├── dyn_dropout_layer_desc.hpp │ │ └── dyn_dropout_layer_impl.hpp │ ├── lstm │ │ ├── dyn_lstm_layer.hpp │ │ ├── dyn_lstm_layer_desc.hpp │ │ ├── dyn_lstm_layer_impl.hpp │ │ ├── lstm_layer.hpp │ │ ├── lstm_layer_desc.hpp │ │ └── lstm_layer_impl.hpp │ ├── recurrent │ │ ├── dyn_embedding_layer.hpp │ │ ├── dyn_embedding_layer_desc.hpp │ │ ├── dyn_embedding_layer_impl.hpp │ │ ├── dyn_recurrent_last_layer.hpp │ │ ├── dyn_recurrent_last_layer_desc.hpp │ │ ├── dyn_recurrent_last_layer_impl.hpp │ │ ├── embedding_layer.hpp │ │ ├── embedding_layer_desc.hpp │ │ ├── embedding_layer_impl.hpp │ │ ├── recurrent_last_layer.hpp │ │ ├── recurrent_last_layer_desc.hpp │ │ └── recurrent_last_layer_impl.hpp │ └── rnn │ │ ├── dyn_rnn_layer.hpp │ │ ├── dyn_rnn_layer_desc.hpp │ │ ├── dyn_rnn_layer_impl.hpp │ │ ├── rnn_layer.hpp │ │ ├── rnn_layer_desc.hpp │ │ └── rnn_layer_impl.hpp │ ├── neural_layer.hpp │ ├── neural_layer_no_bias.hpp │ ├── ocv_visualizer.hpp │ ├── output.hpp │ ├── pooling │ ├── avgp_layer.hpp │ ├── avgp_layer_desc.hpp │ ├── avgp_layer_impl.hpp │ ├── dyn_avgp_layer.hpp │ ├── dyn_avgp_layer_desc.hpp │ ├── dyn_avgp_layer_impl.hpp │ ├── dyn_mp_layer.hpp │ ├── dyn_mp_layer_desc.hpp │ ├── dyn_mp_layer_impl.hpp │ ├── dyn_upsample_layer.hpp │ ├── dyn_upsample_layer_desc.hpp │ ├── dyn_upsample_layer_impl.hpp │ ├── mp_layer.hpp │ ├── mp_layer_desc.hpp │ ├── mp_layer_impl.hpp │ ├── pooling_layer.hpp │ ├── pooling_layer_desc.hpp │ ├── unpooling_layer.hpp │ ├── unpooling_layer_desc.hpp │ ├── upsample_layer.hpp │ ├── upsample_layer_desc.hpp │ └── upsample_layer_impl.hpp │ ├── processor │ └── processor.hpp │ ├── rbm │ ├── conv_rbm.hpp │ ├── conv_rbm_desc.hpp │ ├── conv_rbm_impl.hpp │ ├── conv_rbm_mp.hpp │ ├── conv_rbm_mp_desc.hpp │ ├── conv_rbm_mp_impl.hpp │ ├── dyn_conv_rbm.hpp │ ├── dyn_conv_rbm_desc.hpp │ ├── dyn_conv_rbm_impl.hpp │ ├── dyn_conv_rbm_mp.hpp │ ├── dyn_conv_rbm_mp_desc.hpp │ ├── dyn_conv_rbm_mp_impl.hpp │ ├── dyn_rbm.hpp │ ├── dyn_rbm_desc.hpp │ ├── dyn_rbm_impl.hpp │ ├── rbm.hpp │ ├── rbm_base.hpp │ ├── rbm_desc.hpp │ ├── rbm_impl.hpp │ ├── rbm_tmp.hpp │ ├── standard_conv_rbm.hpp │ ├── standard_crbm.hpp │ ├── standard_crbm_mp.hpp │ └── standard_rbm.hpp │ ├── short_conf.hpp │ ├── sparsity_method.hpp │ ├── strategy.hpp │ ├── svm_common.hpp │ ├── test.hpp │ ├── text_reader.hpp │ ├── trainer │ ├── conjugate_gradient.hpp │ ├── context_fwd.hpp │ ├── dbn_trainer.hpp │ ├── rbm_trainer.hpp │ ├── rbm_trainer_fwd.hpp │ ├── rbm_training_context.hpp │ └── stochastic_gradient_descent.hpp │ ├── transform │ ├── binarize_layer.hpp │ ├── binarize_layer_desc.hpp │ ├── binarize_layer_impl.hpp │ ├── dyn_lcn_layer.hpp │ ├── dyn_lcn_layer_desc.hpp │ ├── dyn_lcn_layer_impl.hpp │ ├── dyn_shape_1d_layer.hpp │ ├── dyn_shape_1d_layer_desc.hpp │ ├── dyn_shape_1d_layer_impl.hpp │ ├── dyn_shape_3d_layer.hpp │ ├── dyn_shape_3d_layer_desc.hpp │ ├── dyn_shape_3d_layer_impl.hpp │ ├── lcn.hpp │ ├── lcn_layer.hpp │ ├── lcn_layer_desc.hpp │ ├── lcn_layer_impl.hpp │ ├── normalize_layer.hpp │ ├── normalize_layer_desc.hpp │ ├── normalize_layer_impl.hpp │ ├── random_layer.hpp │ ├── random_layer_desc.hpp │ ├── random_layer_impl.hpp │ ├── rectifier_layer.hpp │ ├── rectifier_layer_desc.hpp │ ├── rectifier_layer_impl.hpp │ ├── rectifier_method.hpp │ ├── scale_layer.hpp │ ├── scale_layer_desc.hpp │ ├── scale_layer_impl.hpp │ ├── shape_1d_layer.hpp │ ├── shape_1d_layer_desc.hpp │ ├── shape_1d_layer_impl.hpp │ ├── shape_3d_layer.hpp │ ├── shape_3d_layer_desc.hpp │ ├── shape_3d_layer_impl.hpp │ └── transform_layer.hpp │ ├── unit_type.hpp │ ├── updater_type.hpp │ ├── util │ ├── batch.hpp │ ├── batch_extend.hpp │ ├── batch_reshape.hpp │ ├── blas.hpp │ ├── checks.hpp │ ├── converter.hpp │ ├── export.hpp │ ├── flatten.hpp │ ├── format.hpp │ ├── labels.hpp │ ├── random.hpp │ ├── ready.hpp │ ├── timers.hpp │ └── tmp.hpp │ ├── utility │ ├── dyn_group_layer.hpp │ ├── dyn_group_layer_desc.hpp │ ├── dyn_group_layer_impl.hpp │ ├── dyn_merge_layer.hpp │ ├── dyn_merge_layer_desc.hpp │ ├── dyn_merge_layer_impl.hpp │ ├── group_layer.hpp │ ├── group_layer_desc.hpp │ ├── group_layer_impl.hpp │ ├── merge_layer.hpp │ ├── merge_layer_desc.hpp │ └── merge_layer_impl.hpp │ ├── version.hpp │ └── watcher.hpp ├── logo.png ├── logo_small.png ├── processor ├── include │ ├── layer.hpp │ └── parse_utils.hpp ├── samples │ ├── conv_mnist_scale.conf │ ├── dbn_mnist.conf │ ├── dbn_mnist_real.conf │ ├── dbn_mnist_scale.conf │ ├── dense_mnist_scale.conf │ └── inc_mnist_scale.conf └── src │ ├── layer.cpp │ ├── main.cpp │ ├── parse_utils.cpp │ └── processor.cpp ├── sonar-project.properties ├── test ├── include │ ├── dll_test.hpp │ └── template_test.hpp ├── processor │ ├── cdbn_1.conf │ ├── cdbn_2.conf │ ├── conv_pool_sgd_1.conf │ ├── conv_pool_sgd_2.conf │ ├── conv_pool_sgd_2_verbose.conf │ ├── conv_sgd_1.conf │ ├── conv_sgd_2.conf │ ├── conv_sgd_3.conf │ ├── conv_sgd_4.conf │ ├── conv_sgd_5.conf │ ├── conv_sgd_6.conf │ ├── crbm_1.conf │ ├── crbm_2.conf │ ├── crbm_mp_1.conf │ ├── dbn_cg_1.conf │ ├── dbn_sgd_1.conf │ ├── dbn_sgd_2.conf │ ├── dbn_sgd_3.conf │ ├── dense_sgd_1.conf │ ├── dense_sgd_2.conf │ ├── rbm_1.conf │ ├── rbm_2.conf │ ├── rbm_3.conf │ ├── rbm_4.conf │ ├── rbm_5.conf │ ├── rbm_6.conf │ ├── rbm_7.conf │ ├── rbm_8.conf │ ├── rbm_9.conf │ ├── unit_mnist.conf │ ├── unit_mnist_binary.conf │ ├── unit_mnist_noisy.conf │ ├── unit_mnist_normalized.conf │ ├── unit_mnist_raw.conf │ └── unit_mnist_text_binary.conf ├── src │ ├── misc │ │ ├── autoencoder.cpp │ │ ├── autoencoder_dbn.cpp │ │ ├── cdbn_pooling.cpp │ │ ├── cdbn_sgd_1.cpp │ │ ├── cdbn_sgd_2.cpp │ │ ├── cdbn_sgd_3.cpp │ │ ├── cdbn_sgd_4.cpp │ │ ├── cifar.cpp │ │ ├── conv.cpp │ │ ├── conv_autoencoder.cpp │ │ ├── conv_dbn.cpp │ │ ├── conv_dbn_2.cpp │ │ ├── conv_dbn_mp.cpp │ │ ├── crbm.cpp │ │ ├── crbm_mp.cpp │ │ ├── crbm_mp_relu.cpp │ │ ├── crbm_mp_sparsity.cpp │ │ ├── crbm_relu.cpp │ │ ├── crbm_sparsity.cpp │ │ ├── dbn.cpp │ │ ├── dbn_sgd.cpp │ │ ├── dbn_svm.cpp │ │ ├── dbn_transform.cpp │ │ ├── dense.cpp │ │ ├── dyn_conv.cpp │ │ ├── dyn_conv_dbn.cpp │ │ ├── dyn_crbm.cpp │ │ ├── dyn_crbm_mp.cpp │ │ ├── dyn_dbn.cpp │ │ ├── dyn_dbn_cg.cpp │ │ ├── dyn_dbn_sgd.cpp │ │ ├── dyn_dense.cpp │ │ ├── dyn_rbm.cpp │ │ ├── hybrid.cpp │ │ ├── lenet_dyn_rbm.cpp │ │ ├── lenet_mix.cpp │ │ ├── lenet_rbm.cpp │ │ ├── rbm.cpp │ │ ├── rbm_pcd.cpp │ │ ├── rbm_relu.cpp │ │ ├── rbm_sparsity.cpp │ │ ├── smart.cpp │ │ └── test.cpp │ ├── perf │ │ ├── conv_dbn_mp.cpp │ │ ├── conv_dbn_slow.cpp │ │ ├── crbm_mp_perf.cpp │ │ ├── crbm_perf.cpp │ │ ├── dbn_perf.cpp │ │ ├── dbn_sgd_perf.cpp │ │ ├── dyn_rbm.cpp │ │ ├── kws_perf.cpp │ │ ├── rbm_perf.cpp │ │ └── test.cpp │ └── unit │ │ ├── augmentation.cpp │ │ ├── bn.cpp │ │ ├── cae.cpp │ │ ├── cdbn_1.cpp │ │ ├── cdbn_2.cpp │ │ ├── cdbn_types.cpp │ │ ├── conv_1.cpp │ │ ├── conv_2.cpp │ │ ├── conv_3.cpp │ │ ├── conv_augmentation.cpp │ │ ├── conv_same.cpp │ │ ├── conv_types.cpp │ │ ├── crbm.cpp │ │ ├── crbm_mp.cpp │ │ ├── crbm_mp_types.cpp │ │ ├── crbm_types.cpp │ │ ├── dbn.cpp │ │ ├── dbn_ae.cpp │ │ ├── dbn_types.cpp │ │ ├── dbn_types_test.inl │ │ ├── dense.cpp │ │ ├── dense_types.cpp │ │ ├── dyn_crbm.cpp │ │ ├── dyn_crbm_mp.cpp │ │ ├── dyn_dbn.cpp │ │ ├── dyn_dense.cpp │ │ ├── dyn_rbm.cpp │ │ ├── embedding.cpp │ │ ├── initializer.cpp │ │ ├── lcn.cpp │ │ ├── lstm.cpp │ │ ├── processor.cpp │ │ ├── random.cpp │ │ ├── rbm.cpp │ │ ├── rbm_types.cpp │ │ ├── rectifier.cpp │ │ ├── reg.cpp │ │ ├── rnn.cpp │ │ ├── test.cpp │ │ ├── text_reader.cpp │ │ ├── types_test.inl │ │ └── unit.cpp └── text_db │ ├── images │ ├── 1.dat │ ├── 2.dat │ ├── 3.dat │ ├── 4.dat │ ├── 5.dat │ ├── 6.dat │ ├── 7.dat │ ├── 8.dat │ └── 9.dat │ └── labels │ ├── 1.dat │ ├── 2.dat │ ├── 3.dat │ ├── 4.dat │ ├── 5.dat │ ├── 6.dat │ ├── 7.dat │ ├── 8.dat │ └── 9.dat ├── tests.mk ├── tools ├── compile_dyn.sh ├── compile_dyn_conv.sh ├── compile_memory.sh ├── compilers.sh ├── generate_tests.sh └── test_report.sh ├── view └── src │ ├── crbm_mp_view.cpp │ ├── crbm_view.cpp │ └── rbm_view.cpp └── workbench └── src ├── cifar10_cnn_big_perf.cpp ├── cifar10_cnn_med_perf.cpp ├── cifar10_cnn_small_perf.cpp ├── compile_crbm.cpp ├── compile_crbm_one.cpp ├── compile_dyn_crbm.cpp ├── compile_dyn_crbm_one.cpp ├── compile_dyn_rbm.cpp ├── compile_dyn_rbm_one.cpp ├── compile_hybrid_crbm.cpp ├── compile_hybrid_crbm_one.cpp ├── compile_hybrid_rbm.cpp ├── compile_hybrid_rbm_one.cpp ├── compile_rbm.cpp ├── compile_rbm_one.cpp ├── conv_sgd_perf.cpp ├── conv_types.cpp ├── dae.cpp ├── dyn_perf.cpp ├── imagenet_perf.cpp ├── mnist_ae_perf.cpp ├── mnist_cdbn_perf.cpp ├── mnist_cnn_bn_perf.cpp ├── mnist_cnn_perf.cpp ├── mnist_dbn_perf.cpp ├── mnist_deep_ae_perf.cpp ├── mnist_lstm_perf.cpp ├── mnist_mlp_perf.cpp ├── mnist_rnn_perf.cpp ├── perf_conv.cpp ├── perf_paper.cpp ├── perf_paper_conv.cpp ├── rbm_dae.cpp ├── sgd_debug.cpp └── sgd_perf.cpp /.color_coded: -------------------------------------------------------------------------------- 1 | -x 2 | c++ 3 | -DETL_VECTORIZE_FULL 4 | -DNDEBUG 5 | -ICatch/include 6 | -Ietl/include/ 7 | -Ietl/lib/include 8 | -Iinclude 9 | -Imnist/include/ 10 | -Inice_svm/include 11 | -Wall 12 | -Wdocumentation 13 | -Werror 14 | -Wextra 15 | -Winit-self 16 | -Wno-documentation 17 | -Wno-long-long 18 | -Wsometimes-uninitialized 19 | -Wuninitialized 20 | -std=c++1y 21 | -------------------------------------------------------------------------------- /.github/workflows/make.yml: -------------------------------------------------------------------------------- 1 | name: Linux Build 2 | 3 | on: 4 | push: 5 | branches: [ "master" ] 6 | pull_request: 7 | branches: [ "master" ] 8 | 9 | jobs: 10 | build: 11 | name: Compile and test on Linux 12 | runs-on: ubuntu-latest 13 | container: 14 | image: wichtounet/cpp:latest 15 | strategy: 16 | matrix: 17 | compiler: [gcc, clang] 18 | 19 | steps: 20 | - name: Checkout code 21 | uses: actions/checkout@v3 22 | with: 23 | submodules: recursive 24 | 25 | - name: Build binaries 26 | run: make -j5 release_debug_binaries compiler=${{ matrix.compiler }} 27 | 28 | - name: Build tests 29 | run: make -j5 release_debug_dll_test_unit compiler=${{ matrix.compiler }} 30 | 31 | - name: Run tests 32 | run: make release_debug_test compiler=${{ matrix.compiler }} 33 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore the compilation configurations 2 | release/ 3 | debug/ 4 | release_debug/ 5 | 6 | # Ignore reports generated by the watcher 7 | reports 8 | test_reports 9 | 10 | # Ignore profiling data 11 | perf.data 12 | perf.data.old 13 | *.svg 14 | 15 | # Ignore weights file 16 | /*.dat 17 | 18 | # Ignore Doxygen file 19 | html 20 | latex 21 | 22 | # Ignore files generated by vim plugins 23 | *.pyc 24 | 25 | # Ignore files generated by dll_test 26 | .tmp.features 27 | 28 | # Ignore files generated by dllp 29 | .dbn.cpp 30 | .dbn.out 31 | 32 | # Generated by the makefile for clang tools 33 | dll_file_list 34 | tidy_report_light 35 | tidy_report 36 | 37 | # Ignore clangd cache 38 | .cache 39 | *.plist 40 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "make-utils"] 2 | path = make-utils 3 | url = https://github.com/wichtounet/make-utils.git 4 | branch = master 5 | [submodule "etl"] 6 | path = etl 7 | url = https://github.com/wichtounet/etl.git 8 | branch = master 9 | [submodule "mnist"] 10 | path = mnist 11 | url = https://github.com/wichtounet/mnist.git 12 | branch = master 13 | [submodule "nice_svm"] 14 | path = nice_svm 15 | url = https://github.com/wichtounet/nice_svm.git 16 | [submodule "cifar-10"] 17 | path = cifar-10 18 | url = https://github.com/wichtounet/cifar-10.git 19 | [submodule "doctest"] 20 | path = doctest 21 | url = https://github.com/onqtam/doctest.git 22 | branch = dev 23 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Baptiste Wicht 2 | -------------------------------------------------------------------------------- /ChangeLog.rst: -------------------------------------------------------------------------------- 1 | DLL 1.1 - in development 2 | ++++++++++++++++++++++++ 3 | 4 | * Support for embeddings_layer 5 | * Support for group_layer 6 | * Support for merge_layer 7 | * Support for rnn_layer (Recurrent Neural Network (RNN)) 8 | * Support for lstm_layer (Long Short Term Memory (LSTM)) 9 | * Support for pretty printing and live printing 10 | * Faster Batch Normalization 11 | * GPU Support for dropout 12 | * GPU Support for shuffle 13 | 14 | DLL 1.0 - 06.10.2017 15 | ++++++++++++++++++++ 16 | 17 | Initial version (was rolling released before) with the following main features: 18 | 19 | * RBM and CRBM support 20 | * Deep Belief Network 21 | * Contrastive Divergence 22 | * Stochastic Gradient Descent 23 | * Artificial Neural Networks 24 | * Convolutional Neural Networks 25 | * Auto-Encoders 26 | * Pooling 27 | * Dropout 28 | * Batch Normalization 29 | * Adaptive Learning Rates 30 | * Basic data augmentation 31 | * Datasets support: MNIST, CIFAR-10, ImageNet 32 | * High CPU and GPU performance 33 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014-2023 Baptiste Wicht 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /examples/src/cifar10_cnn.cpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #include "dll/neural/conv/conv_layer.hpp" 9 | #include "dll/neural/dense/dense_layer.hpp" 10 | #include "dll/pooling/mp_layer.hpp" 11 | #include "dll/network.hpp" 12 | #include "dll/datasets.hpp" 13 | 14 | int main(int /*argc*/, char* /*argv*/ []) { 15 | // Load the dataset 16 | auto dataset = dll::make_cifar10_dataset(dll::batch_size<256>{}, dll::scale_pre<255>{}); 17 | 18 | // Build the network 19 | 20 | using network_t = dll::dyn_network_desc< 21 | dll::dbn_layers< 22 | dll::conv_layer<3, 32, 32, 12, 5, 5, dll::relu>, 23 | dll::mp_3d_layer<12, 28, 28, 1, 2, 2>, 24 | dll::conv_layer<12, 14, 14, 24, 3, 3, dll::relu>, 25 | dll::mp_3d_layer<24, 12, 12, 1, 2, 2>, 26 | dll::dense_layer<24 * 6 * 6, 64, dll::relu>, 27 | dll::dense_layer<64, 10, dll::softmax> 28 | >, 29 | dll::updater, 30 | dll::batch_size<256>, 31 | dll::no_batch_display, 32 | dll::no_epoch_error 33 | >::network_t; 34 | 35 | auto net = std::make_unique(); 36 | 37 | // Display the network and dataset 38 | net->display_pretty(); 39 | dataset.display_pretty(); 40 | 41 | // Train the network 42 | net->train(dataset.train(), 5); 43 | 44 | // Test the network on test set 45 | net->evaluate(dataset.test()); 46 | 47 | return 0; 48 | } 49 | -------------------------------------------------------------------------------- /examples/src/mnist_ae.cpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #include "dll/neural/dense/dense_layer.hpp" 9 | #include "dll/network.hpp" 10 | #include "dll/datasets.hpp" 11 | 12 | #include "mnist/mnist_reader.hpp" 13 | #include "mnist/mnist_utils.hpp" 14 | 15 | int main(int /*argc*/, char* /*argv*/ []) { 16 | // Load the dataset 17 | auto dataset = dll::make_mnist_ae_dataset(dll::batch_size<256>{}, dll::scale_pre<255>{}); 18 | 19 | // Build the network 20 | 21 | using network_t = dll::dyn_network_desc< 22 | dll::network_layers< 23 | dll::dense_layer<28 * 28, 32, dll::relu>, 24 | dll::dense_layer<32, 28 * 28, dll::sigmoid> 25 | > 26 | , dll::batch_size<256> // The mini-batch size 27 | , dll::shuffle // Shuffle the dataset before each epoch 28 | , dll::binary_cross_entropy // Use a Binary Cross Entropy Loss 29 | , dll::adadelta // Adadelta updates for gradient descent 30 | >::network_t; 31 | 32 | auto net = std::make_unique(); 33 | 34 | // Display the network and dataset 35 | net->display_pretty(); 36 | dataset.display_pretty(); 37 | 38 | // Train the network as auto-encoder 39 | net->train_ae(dataset.train(), 10); 40 | 41 | // Test the network on test set 42 | net->evaluate_ae(dataset.test()); 43 | 44 | return 0; 45 | } 46 | -------------------------------------------------------------------------------- /examples/src/mnist_cdbn.cpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #include "dll/rbm/conv_rbm.hpp" 9 | #include "dll/rbm/rbm.hpp" 10 | #include "dll/network.hpp" 11 | #include "dll/datasets.hpp" 12 | 13 | int main(int /*argc*/, char* /*argv*/ []) { 14 | // Load the dataset 15 | auto ae_dataset = dll::make_mnist_ae_dataset(dll::batch_size<100>{}, dll::binarize_pre<30>{}); 16 | auto dataset = dll::make_mnist_dataset(dll::batch_size<100>{}, dll::binarize_pre<30>{}); 17 | 18 | // Build the network 19 | 20 | using network_t = dll::network_desc< 21 | dll::network_layers< 22 | dll::conv_rbm_square_desc<1, 28, 8, 9, dll::momentum, dll::batch_size<100>>::layer_t, 23 | dll::conv_rbm_square_desc<8, 20, 8, 5, dll::momentum, dll::batch_size<100>>::layer_t, 24 | dll::rbm<8 * 16 * 16, 1000, dll::batch_size<100>, dll::momentum>, 25 | dll::rbm<1000, 10, dll::batch_size<100>, dll::hidden> 26 | > 27 | , dll::updater // Nesterov Adam (NADAM) 28 | , dll::batch_size<100> // The mini-batch size 29 | , dll::shuffle // Shuffle before each epoch 30 | >::network_t; 31 | 32 | auto net = std::make_unique(); 33 | 34 | // Display the network and dataset 35 | net->display_pretty(); 36 | dataset.display_pretty(); 37 | 38 | // Pretrain the network with contrastive divergence 39 | net->pretrain(ae_dataset.train(), 10); 40 | 41 | // Train the network for performance sake 42 | net->fine_tune(dataset.train(), 50); 43 | 44 | // Test the network on test set 45 | net->evaluate(dataset.test()); 46 | 47 | // Show where the time was spent 48 | dll::dump_timers_pretty(); 49 | 50 | return 0; 51 | } 52 | -------------------------------------------------------------------------------- /examples/src/mnist_cnn.cpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #include "dll/neural/conv/conv_layer.hpp" 9 | #include "dll/neural/dense/dense_layer.hpp" 10 | #include "dll/pooling/mp_layer.hpp" 11 | #include "dll/network.hpp" 12 | #include "dll/datasets.hpp" 13 | 14 | int main(int /*argc*/, char* /*argv*/ []) { 15 | // Load the dataset 16 | auto dataset = dll::make_mnist_dataset(dll::batch_size<200>{}, dll::scale_pre<255>{}); 17 | 18 | // Build the network 19 | 20 | using network_t = dll::dyn_network_desc< 21 | dll::network_layers< 22 | dll::conv_layer<1, 28, 28, 8, 5, 5>, 23 | dll::mp_2d_layer<8, 24, 24, 2, 2>, 24 | dll::conv_layer<8, 12, 12, 8, 5, 5>, 25 | dll::mp_2d_layer<8, 8, 8, 2, 2>, 26 | dll::dense_layer<8 * 4 * 4, 150>, 27 | dll::dense_layer<150, 10, dll::softmax> 28 | > 29 | , dll::updater // Momentum 30 | , dll::batch_size<200> // The mini-batch size 31 | , dll::shuffle // Shuffle the dataset before each epoch 32 | >::network_t; 33 | 34 | auto net = std::make_unique(); 35 | 36 | // Display the network and dataset 37 | net->display_pretty(); 38 | dataset.display_pretty(); 39 | 40 | // Train the network 41 | net->train(dataset.train(), 5); 42 | 43 | // Test the network on test set 44 | net->evaluate(dataset.test()); 45 | 46 | return 0; 47 | } 48 | -------------------------------------------------------------------------------- /examples/src/mnist_dbn.cpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #include "dll/rbm/rbm.hpp" 9 | #include "dll/network.hpp" 10 | #include "dll/datasets.hpp" 11 | 12 | int main(int /*argc*/, char* /*argv*/ []) { 13 | // Load the dataset 14 | auto ae_dataset = dll::make_mnist_ae_dataset(dll::batch_size<100>{}, dll::binarize_pre<30>{}); 15 | auto dataset = dll::make_mnist_dataset(dll::batch_size<100>{}, dll::binarize_pre<30>{}); 16 | 17 | // Build the network 18 | 19 | using network_t = dll::network_desc< 20 | dll::network_layers< 21 | dll::rbm<28 * 28, 500, dll::batch_size<100>, dll::momentum>, 22 | dll::rbm<500, 250, dll::batch_size<100>, dll::momentum>, 23 | dll::rbm<250, 10, dll::batch_size<100>, dll::hidden> 24 | > 25 | , dll::updater // Nesterov Adam (NADAM) 26 | , dll::batch_size<100> // The mini-batch size 27 | , dll::shuffle // Shuffle before each epoch 28 | >::network_t; 29 | 30 | auto net = std::make_unique(); 31 | 32 | // Display the network and dataset 33 | net->display_pretty(); 34 | dataset.display_pretty(); 35 | 36 | // Pretrain the network with contrastive divergence 37 | net->pretrain(ae_dataset.train(), 10); 38 | 39 | // Train the network for performance sake 40 | net->fine_tune(dataset.train(), 50); 41 | 42 | // Test the network on test set 43 | net->evaluate(dataset.test()); 44 | 45 | // Show where the time was spent 46 | dll::dump_timers_pretty(); 47 | 48 | return 0; 49 | } 50 | -------------------------------------------------------------------------------- /examples/src/mnist_deep_ae.cpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #include "dll/neural/dense/dense_layer.hpp" 9 | #include "dll/network.hpp" 10 | #include "dll/datasets.hpp" 11 | 12 | #include "mnist/mnist_reader.hpp" 13 | #include "mnist/mnist_utils.hpp" 14 | 15 | int main(int /*argc*/, char* /*argv*/ []) { 16 | // Load the dataset 17 | auto dataset = dll::make_mnist_ae_dataset(dll::batch_size<256>{}, dll::scale_pre<255>{}); 18 | 19 | // Build the network 20 | 21 | using network_t = dll::dyn_network_desc< 22 | dll::network_layers< 23 | dll::dense_layer_desc<784, 128, dll::relu>::layer_t, 24 | dll::dense_layer_desc<128, 64 , dll::relu>::layer_t, 25 | dll::dense_layer_desc<64 , 32 , dll::relu>::layer_t, 26 | // Encoded Features 27 | dll::dense_layer_desc<32 , 64 , dll::relu>::layer_t, 28 | dll::dense_layer_desc<64 , 128, dll::relu>::layer_t, 29 | dll::dense_layer_desc<128, 784, dll::sigmoid>::layer_t 30 | > 31 | , dll::batch_size<256> // The mini-batch size 32 | , dll::shuffle // Shuffle the dataset before each epoch 33 | , dll::binary_cross_entropy // Use a Binary Cross Entropy Loss 34 | , dll::adadelta // Adadelta updates for gradient descent 35 | >::network_t; 36 | 37 | auto net = std::make_unique(); 38 | 39 | // Display the network 40 | net->display(); 41 | 42 | // Train the network as auto-encoder 43 | net->train_ae(dataset.train(), 50); 44 | 45 | // Test the network on test set 46 | net->evaluate_ae(dataset.test()); 47 | 48 | return 0; 49 | } 50 | -------------------------------------------------------------------------------- /examples/src/mnist_lstm.cpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #include "dll/neural/dense/dense_layer.hpp" 9 | #include "dll/neural/lstm/lstm_layer.hpp" 10 | #include "dll/neural/recurrent/recurrent_last_layer.hpp" 11 | #include "dll/network.hpp" 12 | #include "dll/datasets.hpp" 13 | 14 | int main(int /*argc*/, char* /*argv*/ []) { 15 | // Load the dataset 16 | auto dataset = dll::make_mnist_dataset_nc(dll::batch_size<100>{}, dll::scale_pre<255>{}); 17 | 18 | constexpr size_t time_steps = 28; 19 | constexpr size_t sequence_length = 28; 20 | constexpr size_t hidden_units = 100; 21 | 22 | // Build the network 23 | 24 | using network_t = dll::dyn_network_desc< 25 | dll::network_layers< 26 | dll::lstm_layer, 27 | dll::recurrent_last_layer, 28 | dll::dense_layer 29 | > 30 | , dll::updater // Adam 31 | , dll::batch_size<100> // The mini-batch size 32 | >::network_t; 33 | 34 | auto net = std::make_unique(); 35 | 36 | // Display the network and dataset 37 | net->display_pretty(); 38 | dataset.display_pretty(); 39 | 40 | // Train the network for performance sake 41 | net->train(dataset.train(), 50); 42 | 43 | // Test the network on test set 44 | net->evaluate(dataset.test()); 45 | 46 | return 0; 47 | } 48 | -------------------------------------------------------------------------------- /examples/src/mnist_mlp.cpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #include "dll/neural/dense/dense_layer.hpp" 9 | #include "dll/neural/dropout/dropout_layer.hpp" 10 | #include "dll/network.hpp" 11 | #include "dll/datasets.hpp" 12 | 13 | int main(int /*argc*/, char* /*argv*/ []) { 14 | // Load the dataset 15 | auto dataset = dll::make_mnist_dataset(dll::batch_size<100>{}, dll::normalize_pre{}); 16 | 17 | // Build the network 18 | 19 | using network_t = dll::dyn_network_desc< 20 | dll::network_layers< 21 | dll::dense_layer<28 * 28, 500>, 22 | dll::dropout_layer<50>, 23 | dll::dense_layer<500, 250>, 24 | dll::dropout_layer<50>, 25 | dll::dense_layer<250, 10, dll::softmax> 26 | > 27 | , dll::updater // Nesterov Adam (NADAM) 28 | , dll::batch_size<100> // The mini-batch size 29 | , dll::shuffle // Shuffle before each epoch 30 | >::network_t; 31 | 32 | auto net = std::make_unique(); 33 | 34 | // Display the network and dataset 35 | net->display_pretty(); 36 | dataset.display_pretty(); 37 | 38 | // Train the network for performance sake 39 | net->train(dataset.train(), 5); 40 | 41 | // Test the network on test set 42 | net->evaluate(dataset.test()); 43 | 44 | return 0; 45 | } 46 | -------------------------------------------------------------------------------- /examples/src/mnist_rnn.cpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #include "dll/neural/dense/dense_layer.hpp" 9 | #include "dll/neural/rnn/rnn_layer.hpp" 10 | #include "dll/neural/recurrent/recurrent_last_layer.hpp" 11 | #include "dll/network.hpp" 12 | #include "dll/datasets.hpp" 13 | 14 | int main(int /*argc*/, char* /*argv*/ []) { 15 | // Load the dataset 16 | auto dataset = dll::make_mnist_dataset_nc(dll::batch_size<100>{}, dll::scale_pre<255>{}); 17 | 18 | constexpr size_t time_steps = 28; 19 | constexpr size_t sequence_length = 28; 20 | constexpr size_t hidden_units = 100; 21 | 22 | // Build the network 23 | 24 | using network_t = dll::dyn_network_desc< 25 | dll::network_layers< 26 | dll::rnn_layer, 27 | dll::recurrent_last_layer, 28 | dll::dense_layer 29 | > 30 | , dll::updater // Adam 31 | , dll::batch_size<100> // The mini-batch size 32 | >::network_t; 33 | 34 | auto net = std::make_unique(); 35 | 36 | // Display the network and dataset 37 | net->display(); 38 | dataset.display(); 39 | 40 | // Train the network for performance sake 41 | net->train(dataset.train(), 50); 42 | 43 | // Test the network on test set 44 | net->evaluate(dataset.test()); 45 | 46 | return 0; 47 | } 48 | -------------------------------------------------------------------------------- /include/dll/base_traits.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | namespace dll { 11 | 12 | template 13 | struct layer_base_traits; 14 | 15 | template 16 | struct rbm_layer_base_traits; 17 | 18 | } //end of dll namespace 19 | -------------------------------------------------------------------------------- /include/dll/bias_mode.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | namespace dll { 11 | 12 | /*! 13 | * \brief Several modes for biases computation in convolutional RBM 14 | */ 15 | enum class bias_mode { 16 | NONE, ///< The sparsity bias is not computed 17 | SIMPLE ///< The sparsity bias is computed on the visible biases 18 | }; 19 | 20 | } //end of dll namespace 21 | -------------------------------------------------------------------------------- /include/dll/dbn.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | #include "dll/generators.hpp" 11 | 12 | #include "dll/layer_traits.hpp" 13 | #include "dll/network_layers.hpp" 14 | #include "dll/network_impl.hpp" 15 | #include "dll/network_desc.hpp" 16 | -------------------------------------------------------------------------------- /include/dll/decay_type.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | namespace dll { 11 | 12 | /*! 13 | * \brief Define how weight decay is applied. 14 | */ 15 | enum class decay_type { 16 | NONE, ///< No weight decay is applied during training 17 | L1, ///< Apply L1 weight decay on weights 18 | L1_FULL, ///< Apply L1 weight decay on weights and biases 19 | L2, ///< Apply L2 weight decay on weights 20 | L2_FULL, ///< Apply L2 weight decay on weights and biases 21 | L1L2, ///< Apply L1/L2 weight decay on weights 22 | L1L2_FULL ///< Apply L1/L2 weight decay on weights and biases 23 | }; 24 | 25 | /*! 26 | * \brief Indicates the type of decay that is to be applied to weights 27 | * \param t The RBM weight decay type. 28 | * \return one of L1,L2,NONE 29 | */ 30 | constexpr decay_type w_decay(decay_type t) { 31 | return 32 | (t == decay_type::L1 || t == decay_type::L1_FULL) ? decay_type::L1 : 33 | (t == decay_type::L2 || t == decay_type::L2_FULL) ? decay_type::L2 : 34 | (t == decay_type::L1L2 || t == decay_type::L1L2_FULL) ? decay_type::L1L2 35 | : decay_type::NONE; 36 | } 37 | 38 | /*! 39 | * \brief Indicates the type of decay that is to be applied to biases 40 | * \param t The RBM weight decay type. 41 | * \return one of L1,L2,NONE 42 | */ 43 | constexpr decay_type b_decay(decay_type t) { 44 | return t == decay_type::L1_FULL ? decay_type::L1 : t == decay_type::L2_FULL ? decay_type::L2 : t == decay_type::L1L2_FULL ? decay_type::L1L2 : decay_type::NONE; 45 | } 46 | 47 | } //end of dll namespace 48 | -------------------------------------------------------------------------------- /include/dll/dll.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | /*! \fileThis file is just here to make Doxygen generates namespaces... */ 9 | 10 | #error "Documentation only" 11 | 12 | /*! 13 | * namespace for Deep Learning Library (DLL) 14 | */ 15 | namespace dll { 16 | 17 | /*! 18 | * namespace keeping implementation details, mostly TMP stuff. 19 | */ 20 | namespace detail {} 21 | 22 | } //end of namespace detail -------------------------------------------------------------------------------- /include/dll/loss.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | /*! 9 | * \file loss.hpp 10 | * \brief Losses for neural network training 11 | */ 12 | 13 | #pragma once 14 | 15 | namespace dll { 16 | 17 | /*! 18 | * \brief An activation function 19 | */ 20 | enum class loss_function { 21 | CATEGORICAL_CROSS_ENTROPY, ///< Categorical Cross Entropy Loss 22 | BINARY_CROSS_ENTROPY, ///< Binary Cross Entropy Loss 23 | MEAN_SQUARED_ERROR ///< Mean Squared Error Loss 24 | }; 25 | 26 | /*! 27 | * \brief Returns a string representation of a loss function 28 | * \param f The loss to transform to string 29 | * \return a string representation of a loss function 30 | */ 31 | inline std::string to_string(loss_function f) { 32 | switch (f) { 33 | case loss_function::CATEGORICAL_CROSS_ENTROPY: 34 | return "CATEGORICAL_CROSS_ENTROPY"; 35 | case loss_function::BINARY_CROSS_ENTROPY: 36 | return "BINARY_CROSS_ENTROPY"; 37 | case loss_function::MEAN_SQUARED_ERROR: 38 | return "MEAN_SQUARED_ERROR"; 39 | } 40 | 41 | cpp_unreachable("Unreachable code"); 42 | 43 | return "UNDEFINED"; 44 | } 45 | 46 | } //end of dll namespace 47 | -------------------------------------------------------------------------------- /include/dll/network.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | #include "dll/generators.hpp" 11 | 12 | #include "dll/layer_traits.hpp" 13 | #include "dll/network_layers.hpp" 14 | #include "dll/network_impl.hpp" 15 | #include "dll/network_desc.hpp" 16 | -------------------------------------------------------------------------------- /include/dll/neural/activation/activation_layer.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | #include "dll/neural/activation/activation_layer_impl.hpp" 11 | #include "dll/neural/activation/activation_layer_desc.hpp" 12 | -------------------------------------------------------------------------------- /include/dll/neural/activation/activation_layer_desc.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | namespace dll { 11 | 12 | /*! 13 | * \brief A descriptor for an activation layer. 14 | * 15 | * Such a layer only applies an activation function to its inputs 16 | * and has no weights. 17 | */ 18 | template 19 | struct activation_layer_desc { 20 | /*! 21 | * \brief The layer's activation function 22 | */ 23 | static constexpr function activation_function = F; 24 | 25 | /*! 26 | * The layer type 27 | */ 28 | using layer_t = activation_layer_impl>; 29 | 30 | /*! 31 | * The dynamic layer type 32 | */ 33 | using dyn_layer_t = activation_layer_impl>; 34 | }; 35 | 36 | /*! 37 | * \brief A descriptor for an activation layer. 38 | * 39 | * Such a layer only applies an activation function to its inputs 40 | * and has no weights. 41 | */ 42 | template 43 | using activation_layer = typename activation_layer_desc::layer_t; 44 | 45 | } //end of dll namespace 46 | -------------------------------------------------------------------------------- /include/dll/neural/bn/batch_normalization_layer.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | #include "dll/neural/bn/batch_normalization_2d_layer_impl.hpp" 11 | #include "dll/neural/bn/batch_normalization_4d_layer_impl.hpp" 12 | 13 | #include "dll/neural/bn/dyn_batch_normalization_2d_layer_impl.hpp" 14 | #include "dll/neural/bn/dyn_batch_normalization_4d_layer_impl.hpp" 15 | 16 | #include "dll/neural/bn/batch_normalization_layer_desc.hpp" 17 | -------------------------------------------------------------------------------- /include/dll/neural/conv/conv_layer.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | // Include the dyn version (for dyn_dbn) 11 | #include "dll/neural/conv/dyn_conv_layer.hpp" 12 | 13 | #include "dll/neural/conv/conv_layer_impl.hpp" 14 | #include "dll/neural/conv/conv_layer_desc.hpp" 15 | -------------------------------------------------------------------------------- /include/dll/neural/conv/conv_same_layer.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | // Include the dyn version (for dyn_dbn) 11 | #include "dll/neural/conv/dyn_conv_same_layer.hpp" 12 | 13 | #include "dll/neural/conv/conv_same_layer_impl.hpp" 14 | #include "dll/neural/conv/conv_same_desc.hpp" 15 | -------------------------------------------------------------------------------- /include/dll/neural/conv/deconv_layer.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | // Include the dyn version (for dyn_dbn) 11 | #include "dll/neural/conv/dyn_deconv_layer.hpp" 12 | 13 | #include "dll/neural/conv/deconv_layer_impl.hpp" 14 | #include "dll/neural/conv/deconv_layer_desc.hpp" 15 | -------------------------------------------------------------------------------- /include/dll/neural/conv/dyn_conv_layer.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | #include "dll/neural/conv/dyn_conv_layer_impl.hpp" 11 | #include "dll/neural/conv/dyn_conv_layer_desc.hpp" 12 | -------------------------------------------------------------------------------- /include/dll/neural/conv/dyn_conv_same_layer.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | #include "dll/neural/conv/dyn_conv_same_layer_impl.hpp" 11 | #include "dll/neural/conv/dyn_conv_same_desc.hpp" 12 | -------------------------------------------------------------------------------- /include/dll/neural/conv/dyn_deconv_layer.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | #include "dll/neural/conv/dyn_deconv_layer_impl.hpp" 11 | #include "dll/neural/conv/dyn_deconv_layer_desc.hpp" 12 | -------------------------------------------------------------------------------- /include/dll/neural/conv/dyn_deconv_layer_desc.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | #include "dll/base_conf.hpp" 11 | #include "dll/util/tmp.hpp" 12 | 13 | namespace dll { 14 | 15 | /*! 16 | * \brief Describe a standard dynamic deconvolutional layer. 17 | */ 18 | template 19 | struct dyn_deconv_layer_desc { 20 | /*! 21 | * \brief A list of all the parameters of the descriptor 22 | */ 23 | using parameters = cpp::type_list; 24 | 25 | static constexpr auto activation_function = detail::get_value_v, Parameters...>; ///< The layer's activation function 26 | 27 | using w_initializer = detail::get_type_t, Parameters...>; ///< The initializer for the weights 28 | using b_initializer = detail::get_type_t, Parameters...>; ///< The initializer for the biases 29 | 30 | /*! The type used to store the weights */ 31 | using weight = detail::get_type_t, Parameters...>; 32 | 33 | /*! The layer type */ 34 | using layer_t = dyn_deconv_layer_impl>; 35 | 36 | /*! The dynamic layer type */ 37 | using dyn_layer_t = layer_t; 38 | 39 | //Make sure only valid types are passed to the configuration list 40 | static_assert( 41 | detail::is_valid_v, Parameters...>, 42 | "Invalid parameters type for dyn_deconv_layer_desc"); 43 | }; 44 | 45 | /*! 46 | * \brief Describe a standard dynamic deconvolutional layer. 47 | */ 48 | template 49 | using dyn_deconv_layer = typename dyn_deconv_layer_desc::layer_t; 50 | 51 | } //end of dll namespace 52 | -------------------------------------------------------------------------------- /include/dll/neural/dense/dense_layer.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | // Include the dyn version (for dyn_dbn) 11 | #include "dll/neural/dense/dyn_dense_layer.hpp" 12 | 13 | #include "dll/neural/dense/dense_layer_impl.hpp" 14 | #include "dll/neural/dense/dense_layer_desc.hpp" 15 | -------------------------------------------------------------------------------- /include/dll/neural/dense/dyn_dense_layer.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | #include "dll/neural/dense/dyn_dense_layer_impl.hpp" 11 | #include "dll/neural/dense/dyn_dense_layer_desc.hpp" 12 | -------------------------------------------------------------------------------- /include/dll/neural/dense/dyn_dense_layer_desc.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | #include "dll/base_conf.hpp" 11 | #include "dll/util/tmp.hpp" 12 | 13 | namespace dll { 14 | 15 | /*! 16 | * \brief Describe a dense layer. 17 | */ 18 | template 19 | struct dyn_dense_layer_desc { 20 | /*! 21 | * A list of all the parameters of the descriptor 22 | */ 23 | using parameters = cpp::type_list; 24 | 25 | static constexpr auto activation_function = detail::get_value_v, Parameters...>; ///< The layer's activation function 26 | 27 | using w_initializer = detail::get_type_t, Parameters...>; ///< The initializer for the weights 28 | using b_initializer = detail::get_type_t, Parameters...>; ///< The initializer for the biases 29 | 30 | /*! The type used to store the weights */ 31 | using weight = detail::get_type_t, Parameters...>; 32 | 33 | /*! The dense type */ 34 | using layer_t = dyn_dense_layer_impl>; 35 | 36 | /*! The dense type */ 37 | using dyn_layer_t = dyn_dense_layer_impl>; 38 | 39 | //Make sure only valid types are passed to the configuration list 40 | static_assert( 41 | detail::is_valid_v< 42 | cpp::type_list, 43 | Parameters...>, 44 | "Invalid parameters type for dense_layer_desc"); 45 | }; 46 | 47 | /*! 48 | * \brief Describe a dense layer. 49 | */ 50 | template 51 | using dyn_dense_layer = typename dyn_dense_layer_desc::layer_t; 52 | 53 | } //end of dll namespace 54 | -------------------------------------------------------------------------------- /include/dll/neural/dropout/dropout_layer.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | #include "dll/neural/dropout/dyn_dropout_layer.hpp" 11 | 12 | #include "dll/neural/dropout/dropout_layer_impl.hpp" 13 | #include "dll/neural/dropout/dropout_layer_desc.hpp" 14 | -------------------------------------------------------------------------------- /include/dll/neural/dropout/dropout_layer_desc.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | namespace dll { 11 | 12 | /*! 13 | * \brief A descriptor for a dropout layer. 14 | */ 15 | template 16 | struct dropout_layer_desc { 17 | static_assert(D > 0, "Invalid dropout factor"); 18 | static_assert(D < 101, "Invalid dropout factor"); 19 | 20 | /*! 21 | * \brief Drop percentage 22 | */ 23 | static constexpr size_t Drop = D; 24 | 25 | /*! 26 | * The layer type 27 | */ 28 | using layer_t = dropout_layer_impl>; 29 | 30 | /*! 31 | * The dynamic layer type 32 | */ 33 | using dyn_layer_t = dyn_dropout_layer_impl; 34 | }; 35 | 36 | /*! 37 | * \brief A descriptor for a dropout layer. 38 | */ 39 | template 40 | using dropout_layer = typename dropout_layer_desc::layer_t; 41 | 42 | } //end of dll namespace 43 | -------------------------------------------------------------------------------- /include/dll/neural/dropout/dyn_dropout_layer.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | #include "dll/neural/dropout/dyn_dropout_layer_impl.hpp" 11 | #include "dll/neural/dropout/dyn_dropout_layer_desc.hpp" 12 | -------------------------------------------------------------------------------- /include/dll/neural/dropout/dyn_dropout_layer_desc.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | namespace dll { 11 | 12 | /*! 13 | * \brief A descriptor for a dropout layer. 14 | */ 15 | struct dyn_dropout_layer_desc { 16 | /*! 17 | * The layer type 18 | */ 19 | using layer_t = dyn_dropout_layer_impl; 20 | 21 | /*! 22 | * The dynamic layer type 23 | */ 24 | using dyn_layer_t = dyn_dropout_layer_impl; 25 | }; 26 | 27 | /*! 28 | * \brief A descriptor for a dropout layer. 29 | */ 30 | using dyn_dropout_layer = typename dyn_dropout_layer_desc::layer_t; 31 | 32 | } //end of dll namespace 33 | -------------------------------------------------------------------------------- /include/dll/neural/lstm/dyn_lstm_layer.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | #include "dll/neural/lstm/dyn_lstm_layer_impl.hpp" 11 | #include "dll/neural/lstm/dyn_lstm_layer_desc.hpp" 12 | -------------------------------------------------------------------------------- /include/dll/neural/lstm/lstm_layer.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | #include "dll/neural/lstm/dyn_lstm_layer.hpp" 11 | 12 | #include "dll/neural/lstm/lstm_layer_impl.hpp" 13 | #include "dll/neural/lstm/lstm_layer_desc.hpp" 14 | -------------------------------------------------------------------------------- /include/dll/neural/recurrent/dyn_embedding_layer.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | #include "dll/neural/recurrent/dyn_embedding_layer_impl.hpp" 11 | #include "dll/neural/recurrent/dyn_embedding_layer_desc.hpp" 12 | -------------------------------------------------------------------------------- /include/dll/neural/recurrent/dyn_embedding_layer_desc.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | #include "dll/base_conf.hpp" 11 | #include "dll/util/tmp.hpp" 12 | 13 | namespace dll { 14 | 15 | /*! 16 | * \brief Describe a standard embedding layer. 17 | */ 18 | template 19 | struct dyn_embedding_layer_desc { 20 | /*! 21 | * \brief A list of all the parameters of the descriptor 22 | */ 23 | using parameters = cpp::type_list; 24 | 25 | using w_initializer = detail::get_type_t>, Parameters...>; ///< The initializer for the weights 26 | 27 | /*! The type used to store the weights */ 28 | using weight = detail::get_type_t, Parameters...>; 29 | 30 | /*! The embedding type */ 31 | using layer_t = dyn_embedding_layer_impl>; 32 | 33 | /*! The embedding type */ 34 | using dyn_layer_t = dyn_embedding_layer_impl>; 35 | 36 | //Make sure only valid types are passed to the configuration list 37 | static_assert( 38 | detail::is_valid_v, Parameters...>, 39 | "Invalid parameters type for dyn_embedding_layer_desc"); 40 | }; 41 | 42 | /*! 43 | * \brief Describe a standard embedding layer. 44 | */ 45 | template 46 | using dyn_embedding_layer = typename dyn_embedding_layer_desc::layer_t; 47 | 48 | } //end of dll namespace 49 | -------------------------------------------------------------------------------- /include/dll/neural/recurrent/dyn_recurrent_last_layer.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | #include "dll/neural/recurrent/dyn_recurrent_last_layer_impl.hpp" 11 | #include "dll/neural/recurrent/dyn_recurrent_last_layer_desc.hpp" 12 | -------------------------------------------------------------------------------- /include/dll/neural/recurrent/dyn_recurrent_last_layer_desc.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | #include "dll/base_conf.hpp" 11 | #include "dll/util/tmp.hpp" 12 | 13 | namespace dll { 14 | 15 | /*! 16 | * \brief Descriptor for a recurrent last layer 17 | */ 18 | template 19 | struct dyn_recurrent_last_layer_desc { 20 | /*! 21 | * A list of all the parameters of the descriptor 22 | */ 23 | using parameters = cpp::type_list; 24 | 25 | /*! The type used to store the weights */ 26 | using weight = detail::get_type_t, Parameters...>; 27 | 28 | /*! The fast type */ 29 | using layer_t = dyn_recurrent_last_layer_impl>; 30 | 31 | /*! The dynamic type */ 32 | using dyn_layer_t = dyn_recurrent_last_layer_impl>; 33 | 34 | //Make sure only valid types are passed to the configuration list 35 | static_assert( 36 | detail::is_valid_v, 38 | Parameters...>, 39 | "Invalid parameters type for recurrent_last_layer_desc"); 40 | }; 41 | 42 | /*! 43 | * \brief Describe a dense layer 44 | */ 45 | template 46 | using dyn_recurrent_last_layer = typename dyn_recurrent_last_layer_desc::layer_t; 47 | 48 | } //end of dll namespace 49 | -------------------------------------------------------------------------------- /include/dll/neural/recurrent/embedding_layer.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | // Include the dyn version (for dyn_dbn) 11 | #include "dll/neural/recurrent/dyn_embedding_layer.hpp" 12 | 13 | #include "dll/neural/recurrent/embedding_layer_impl.hpp" 14 | #include "dll/neural/recurrent/embedding_layer_desc.hpp" 15 | -------------------------------------------------------------------------------- /include/dll/neural/recurrent/recurrent_last_layer.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | #include "dll/neural/recurrent/dyn_recurrent_last_layer.hpp" 11 | 12 | #include "dll/neural/recurrent/recurrent_last_layer_impl.hpp" 13 | #include "dll/neural/recurrent/recurrent_last_layer_desc.hpp" 14 | -------------------------------------------------------------------------------- /include/dll/neural/rnn/dyn_rnn_layer.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | #include "dll/neural/rnn/dyn_rnn_layer_impl.hpp" 11 | #include "dll/neural/rnn/dyn_rnn_layer_desc.hpp" 12 | -------------------------------------------------------------------------------- /include/dll/neural/rnn/rnn_layer.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | #include "dll/neural/rnn/dyn_rnn_layer.hpp" 11 | 12 | #include "dll/neural/rnn/rnn_layer_impl.hpp" 13 | #include "dll/neural/rnn/rnn_layer_desc.hpp" 14 | -------------------------------------------------------------------------------- /include/dll/output.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #include "dll/util/random.hpp" 9 | 10 | /*! 11 | * \brief Output policies for the network 12 | */ 13 | 14 | #pragma once 15 | 16 | namespace dll { 17 | 18 | /*! 19 | * \brief Default output policy 20 | */ 21 | struct default_output_policy { 22 | /*! 23 | * \brief Display the given value 24 | * 25 | * \param value The value to display 26 | */ 27 | template 28 | default_output_policy& operator<<(T&& value) { 29 | std::cout << std::forward(value); 30 | 31 | return *this; 32 | } 33 | 34 | using manipulator = std::ostream& (std::ostream&); 35 | 36 | /*! 37 | * \brief Apply the given manipulator. 38 | * 39 | * \param m The manipulator to apply 40 | */ 41 | default_output_policy& operator<<(manipulator& m) { 42 | std::cout << m; 43 | 44 | return *this; 45 | } 46 | }; 47 | 48 | /*! 49 | * \brief Null output policy 50 | */ 51 | struct null_output_policy { 52 | using manipulator = std::ostream& (std::ostream&); 53 | 54 | /*! 55 | * \brief Display the given value 56 | * 57 | * \param value The value to display 58 | */ 59 | template 60 | null_output_policy& operator<<([[maybe_unused]] T&& value) { 61 | return *this; 62 | } 63 | 64 | /*! 65 | * \brief Apply the given manipulator. 66 | * 67 | * \param m The manipulator to apply 68 | */ 69 | null_output_policy& operator<<([[maybe_unused]] manipulator& m) { 70 | return *this; 71 | } 72 | }; 73 | 74 | } //end of dll namespace 75 | -------------------------------------------------------------------------------- /include/dll/pooling/avgp_layer.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | // Include the dyn version (for dyn_dbn) 11 | #include "dll/pooling/dyn_avgp_layer.hpp" 12 | 13 | #include "dll/pooling/avgp_layer_impl.hpp" 14 | #include "dll/pooling/avgp_layer_desc.hpp" 15 | -------------------------------------------------------------------------------- /include/dll/pooling/dyn_avgp_layer.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | #include "dll/pooling/dyn_avgp_layer_impl.hpp" 11 | #include "dll/pooling/dyn_avgp_layer_desc.hpp" 12 | -------------------------------------------------------------------------------- /include/dll/pooling/dyn_mp_layer.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | #include "dll/pooling/dyn_mp_layer_impl.hpp" 11 | #include "dll/pooling/dyn_mp_layer_desc.hpp" 12 | -------------------------------------------------------------------------------- /include/dll/pooling/dyn_mp_layer_desc.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | #include "pooling_layer_desc.hpp" 11 | 12 | namespace dll { 13 | 14 | /*! 15 | * \brief Description of a Dynamic Max Pooling two-dimensional layer. 16 | */ 17 | template 18 | struct dyn_mp_2d_layer_desc : dyn_pooling_2d_layer_desc { 19 | /*! 20 | * A list of all the parameters of the descriptor 21 | */ 22 | using parameters = cpp::type_list; 23 | 24 | /*! The RBM type */ 25 | using layer_t = dyn_mp_2d_layer_impl>; 26 | 27 | /*! The RBM type */ 28 | using dyn_layer_t = dyn_mp_2d_layer_impl>; 29 | }; 30 | 31 | /*! 32 | * \brief Description of a Dynamic Max Pooling three-dimensional layer. 33 | */ 34 | template 35 | struct dyn_mp_3d_layer_desc : dyn_pooling_3d_layer_desc { 36 | /*! 37 | * A list of all the parameters of the descriptor 38 | */ 39 | using parameters = cpp::type_list; 40 | 41 | /*! The RBM type */ 42 | using layer_t = dyn_mp_3d_layer_impl>; 43 | 44 | /*! The RBM type */ 45 | using dyn_layer_t = dyn_mp_3d_layer_impl>; 46 | }; 47 | 48 | /*! 49 | * \brief Description of a Dynamic Max Pooling two-dimensional layer. 50 | */ 51 | template 52 | using dyn_mp_2d_layer = typename dyn_mp_2d_layer_desc::layer_t; 53 | 54 | /*! 55 | * \brief Description of a Dynamic Max Pooling three-dimensional layer. 56 | */ 57 | template 58 | using dyn_mp_3d_layer = typename dyn_mp_3d_layer_desc::layer_t; 59 | 60 | } //end of dll namespace 61 | -------------------------------------------------------------------------------- /include/dll/pooling/dyn_upsample_layer.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | #include "dll/pooling/dyn_upsample_layer_impl.hpp" 11 | #include "dll/pooling/dyn_upsample_layer_desc.hpp" 12 | -------------------------------------------------------------------------------- /include/dll/pooling/dyn_upsample_layer_desc.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | #include "unpooling_layer_desc.hpp" 11 | 12 | namespace dll { 13 | 14 | /*! 15 | * \brief Descriptor for a dynamic 3D upsample layer 16 | */ 17 | template 18 | struct dyn_upsample_3d_layer_desc : dyn_unpooling_3d_layer_desc { 19 | /*! 20 | * A list of all the parameters of the descriptor 21 | */ 22 | using parameters = cpp::type_list; 23 | 24 | /*! The RBM type */ 25 | using layer_t = dyn_upsample_3d_layer_impl>; 26 | 27 | /*! The RBM type */ 28 | using dyn_layer_t = layer_t; 29 | }; 30 | 31 | /*! 32 | * \brief Descriptor for a dynamic 3D upsample layer 33 | */ 34 | template 35 | using dyn_upsample_3d_layer = typename dyn_upsample_3d_layer_desc::layer_t; 36 | 37 | } //end of dll namespace 38 | -------------------------------------------------------------------------------- /include/dll/pooling/mp_layer.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | // Include the dyn version (for dyn_dbn) 11 | #include "dll/pooling/dyn_mp_layer.hpp" 12 | 13 | #include "dll/pooling/mp_layer_impl.hpp" 14 | #include "dll/pooling/mp_layer_desc.hpp" 15 | -------------------------------------------------------------------------------- /include/dll/pooling/upsample_layer.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | // Include the dyn version (for dyn_dbn) 11 | #include "dll/pooling/dyn_upsample_layer.hpp" 12 | 13 | #include "dll/pooling/upsample_layer_impl.hpp" 14 | #include "dll/pooling/upsample_layer_desc.hpp" 15 | -------------------------------------------------------------------------------- /include/dll/pooling/upsample_layer_desc.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | #include "unpooling_layer_desc.hpp" 11 | 12 | namespace dll { 13 | 14 | /*! 15 | * \brief Descriptor for a 3D upsample layer 16 | */ 17 | template 18 | struct upsample_3d_layer_desc : unpooling_3d_layer_desc { 19 | /*! 20 | * A list of all the parameters of the descriptor 21 | */ 22 | using parameters = cpp::type_list; 23 | 24 | /*! The layer type */ 25 | using layer_t = upsample_3d_layer_impl>; 26 | 27 | /*! The RBM type */ 28 | using dyn_layer_t = dyn_upsample_3d_layer_impl>; 29 | }; 30 | 31 | /*! 32 | * \brief Descriptor for a 3D upsample layer 33 | */ 34 | template 35 | using upsample_3d_layer = typename upsample_3d_layer_desc::layer_t; 36 | 37 | } //end of dll namespace 38 | -------------------------------------------------------------------------------- /include/dll/rbm/conv_rbm.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | // Include the dyn version (for dyn_dbn) 11 | #include "dll/rbm/dyn_conv_rbm.hpp" 12 | 13 | #include "dll/rbm/conv_rbm_impl.hpp" 14 | #include "dll/trainer/rbm_training_context.hpp" 15 | #include "dll/rbm/conv_rbm_desc.hpp" 16 | #include "dll/trainer/rbm_trainer.hpp" 17 | -------------------------------------------------------------------------------- /include/dll/rbm/conv_rbm_mp.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | // Include the dyn version (for dyn_dbn) 11 | #include "dll/rbm/dyn_conv_rbm_mp.hpp" 12 | 13 | #include "dll/rbm/conv_rbm_mp_impl.hpp" 14 | #include "dll/trainer/rbm_training_context.hpp" 15 | #include "dll/rbm/conv_rbm_mp_desc.hpp" 16 | #include "dll/trainer/rbm_trainer.hpp" 17 | -------------------------------------------------------------------------------- /include/dll/rbm/dyn_conv_rbm.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | #include "dll/rbm/dyn_conv_rbm_impl.hpp" 11 | #include "dll/trainer/rbm_training_context.hpp" 12 | #include "dll/rbm/dyn_conv_rbm_desc.hpp" 13 | #include "dll/trainer/rbm_trainer.hpp" 14 | -------------------------------------------------------------------------------- /include/dll/rbm/dyn_conv_rbm_mp.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | #include "dll/rbm/dyn_conv_rbm_mp_impl.hpp" 11 | #include "dll/trainer/rbm_training_context.hpp" 12 | #include "dll/rbm/dyn_conv_rbm_mp_desc.hpp" 13 | #include "dll/trainer/rbm_trainer.hpp" 14 | -------------------------------------------------------------------------------- /include/dll/rbm/dyn_rbm.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | #include "dll/rbm/dyn_rbm_impl.hpp" 11 | #include "dll/trainer/rbm_training_context.hpp" 12 | #include "dll/rbm/dyn_rbm_desc.hpp" 13 | #include "dll/trainer/rbm_trainer.hpp" 14 | -------------------------------------------------------------------------------- /include/dll/rbm/rbm.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | /*! 9 | * \file 10 | * \brief The base include file for a Restricted Boltzmann Machine 11 | */ 12 | 13 | #pragma once 14 | 15 | // Include the dyn version (for dyn_dbn) 16 | #include "dll/rbm/dyn_rbm.hpp" 17 | 18 | #include "dll/rbm/rbm_impl.hpp" 19 | #include "dll/trainer/rbm_training_context.hpp" 20 | #include "dll/rbm/rbm_desc.hpp" 21 | #include "dll/trainer/rbm_trainer.hpp" 22 | -------------------------------------------------------------------------------- /include/dll/rbm/rbm_tmp.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | #include "cpp_utils/tmp.hpp" 11 | -------------------------------------------------------------------------------- /include/dll/sparsity_method.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | namespace dll { 11 | 12 | /*! 13 | * \brief Define how sparsity is applied 14 | */ 15 | enum class sparsity_method { 16 | NONE, ///< Don't train a sparse representation 17 | GLOBAL_TARGET, ///< Sparsity according to (Nair and Hinton, 2009) but using global penalty 18 | LOCAL_TARGET, ///< Sparsity according to (Nair and Hinton, 2009) 19 | LEE ///< Sparsity according to (Lee, 2009) 20 | }; 21 | 22 | } //end of dll namespace 23 | -------------------------------------------------------------------------------- /include/dll/trainer/context_fwd.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | /*! 9 | * \file 10 | * \brief Trainer context forward declarations 11 | */ 12 | 13 | #pragma once 14 | 15 | namespace dll { 16 | 17 | /*! 18 | * \brief The context of a layer during SGD training 19 | * \tparam DBN The containing DBN 20 | * \tparam Layer The layer 21 | */ 22 | template 23 | struct sgd_context; 24 | 25 | /*! 26 | * \brief The context of a RBM during CG training 27 | * \tparam RBM The RBM. 28 | */ 29 | template 30 | struct cg_context {}; 31 | 32 | } //end of dll namespace 33 | -------------------------------------------------------------------------------- /include/dll/trainer/rbm_trainer_fwd.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | namespace dll { 11 | 12 | template 13 | struct rbm_trainer; 14 | 15 | } //end of dll namespace 16 | -------------------------------------------------------------------------------- /include/dll/trainer/rbm_training_context.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | namespace dll { 11 | 12 | /*! 13 | * \brief A container for information collected during training of a RBM. 14 | * 15 | * The values contained in this structure are only valid at the end of the epoch 16 | * training, intermediate values can be contained during intermediate batch 17 | * training. 18 | */ 19 | struct rbm_training_context { 20 | double reconstruction_error = 0.0; ///< The mean reconstruction error 21 | double free_energy = 0.0; ///< The mean free energy 22 | double sparsity = 0.0; ///< The mean sparsity 23 | 24 | double batch_error = 0.0; ///< The mean reconstruction error for the last batch 25 | double batch_sparsity = 0.0; ///< The mean sparsity for the last batch 26 | }; 27 | 28 | } //end of dll namespace 29 | -------------------------------------------------------------------------------- /include/dll/transform/binarize_layer.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | #include "dll/transform/binarize_layer_impl.hpp" 11 | #include "dll/transform/binarize_layer_desc.hpp" 12 | -------------------------------------------------------------------------------- /include/dll/transform/binarize_layer_desc.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | namespace dll { 11 | 12 | /*! 13 | * \brief Descriptor for a binarization layer 14 | */ 15 | template 16 | struct binarize_layer_desc { 17 | static constexpr size_t T = T_T; ///< The binary threshold 18 | 19 | /*! 20 | * A list of all the parameters of the descriptor 21 | */ 22 | using parameters = cpp::type_list<>; 23 | 24 | /*! 25 | * The layer type 26 | */ 27 | using layer_t = binarize_layer_impl>; 28 | 29 | /*! 30 | * The dynamic layer type 31 | */ 32 | using dyn_layer_t = binarize_layer_impl>; 33 | }; 34 | 35 | /*! 36 | * \brief Descriptor for a binarization layer 37 | */ 38 | template 39 | using binarize_layer = typename binarize_layer_desc::layer_t; 40 | 41 | } //end of dll namespace 42 | -------------------------------------------------------------------------------- /include/dll/transform/dyn_lcn_layer.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | #include "dll/transform/dyn_lcn_layer_impl.hpp" 11 | #include "dll/transform/dyn_lcn_layer_desc.hpp" 12 | -------------------------------------------------------------------------------- /include/dll/transform/dyn_lcn_layer_desc.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | namespace dll { 11 | 12 | /*! 13 | * \brief Descriptor for a dynamic Local Contrast Normalization (LCN) layer 14 | */ 15 | struct dyn_lcn_layer_desc { 16 | /*! 17 | * A list of all the parameters of the descriptor 18 | */ 19 | using parameters = cpp::type_list<>; 20 | 21 | /*! The layer type */ 22 | using layer_t = dyn_lcn_layer_impl; 23 | 24 | /*! The layer type */ 25 | using dyn_layer_t = dyn_lcn_layer_impl; 26 | }; 27 | 28 | /*! 29 | * \brief Descriptor for a dynamic Local Contrast Normalization (LCN) layer 30 | */ 31 | using dyn_lcn_layer = typename dyn_lcn_layer_desc::layer_t; 32 | 33 | } //end of dll namespace 34 | -------------------------------------------------------------------------------- /include/dll/transform/dyn_shape_1d_layer.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | #include "dll/transform/dyn_shape_1d_layer_impl.hpp" 11 | #include "dll/transform/dyn_shape_1d_layer_desc.hpp" 12 | -------------------------------------------------------------------------------- /include/dll/transform/dyn_shape_1d_layer_desc.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | namespace dll { 11 | 12 | /*! 13 | * \brief Descriptor for a Dynamic 1D shaping layer. 14 | */ 15 | template 16 | struct dyn_shape_1d_layer_desc { 17 | /*! 18 | * A list of all the parameters of the descriptor 19 | */ 20 | using parameters = cpp::type_list; 21 | 22 | /*! The type used to store the weights */ 23 | using weight = detail::get_type_t, Parameters...>; 24 | 25 | /*! The layer type */ 26 | using layer_t = dyn_shape_1d_layer_impl>; 27 | 28 | /*! The layer type */ 29 | using dyn_layer_t = dyn_shape_1d_layer_impl>; 30 | 31 | //Make sure only valid types are passed to the configuration list 32 | static_assert( 33 | detail::is_valid_v, Parameters...>, 34 | "Invalid parameters type for dyn_shape_1d_layer_desc"); 35 | }; 36 | 37 | /*! 38 | * \brief Descriptor for a Dynamic 1D shaping layer. 39 | */ 40 | template 41 | using dyn_shape_1d_layer = typename dyn_shape_1d_layer_desc::layer_t; 42 | 43 | } //end of dll namespace 44 | -------------------------------------------------------------------------------- /include/dll/transform/dyn_shape_3d_layer.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | #include "dll/transform/dyn_shape_3d_layer_impl.hpp" 11 | #include "dll/transform/dyn_shape_3d_layer_desc.hpp" 12 | -------------------------------------------------------------------------------- /include/dll/transform/dyn_shape_3d_layer_desc.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | namespace dll { 11 | 12 | /*! 13 | * \brief Descriptor for a Dynamic 3D shaping layer. 14 | */ 15 | template 16 | struct dyn_shape_3d_layer_desc { 17 | /*! 18 | * A list of all the parameters of the descriptor 19 | */ 20 | using parameters = cpp::type_list; 21 | 22 | /*! The type used to store the weights */ 23 | using weight = detail::get_type_t, Parameters...>; 24 | 25 | /*! The layer type */ 26 | using layer_t = dyn_shape_3d_layer_impl>; 27 | 28 | /*! The layer type */ 29 | using dyn_layer_t = dyn_shape_3d_layer_impl>; 30 | 31 | //Make sure only valid types are passed to the configuration list 32 | static_assert( 33 | detail::is_valid_v, Parameters...>, 34 | "Invalid parameters type for dyn_shape_3d_layer_desc"); 35 | }; 36 | 37 | /*! 38 | * \brief Descriptor for a Dynamic 3D shaping layer. 39 | */ 40 | template 41 | using dyn_shape_3d_layer = typename dyn_shape_3d_layer_desc::layer_t; 42 | 43 | } //end of dll namespace 44 | -------------------------------------------------------------------------------- /include/dll/transform/lcn_layer.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | // Include the dyn version (for dyn_dbn) 11 | #include "dll/transform/dyn_lcn_layer.hpp" 12 | 13 | #include "dll/transform/lcn_layer_impl.hpp" 14 | #include "dll/transform/lcn_layer_desc.hpp" 15 | -------------------------------------------------------------------------------- /include/dll/transform/lcn_layer_desc.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | namespace dll { 11 | 12 | /*! 13 | * \brief A descriptor for a Local Contrast Normalization layer. 14 | */ 15 | template 16 | struct lcn_layer_desc { 17 | static constexpr size_t K = K_T; ///< The size of the kernel for elastic distortion 18 | 19 | /*! 20 | * A list of all the parameters of the descriptor 21 | */ 22 | using parameters = cpp::type_list<>; 23 | 24 | /*! The layer type */ 25 | using layer_t = lcn_layer_impl>; 26 | 27 | /*! The dynamic layer type */ 28 | using dyn_layer_t = dyn_lcn_layer_impl; 29 | }; 30 | 31 | /*! 32 | * \brief A descriptor for a Local Contrast Normalization layer. 33 | */ 34 | template 35 | using lcn_layer = typename lcn_layer_desc::layer_t; 36 | 37 | } //end of dll namespace 38 | -------------------------------------------------------------------------------- /include/dll/transform/normalize_layer.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | #include "dll/transform/normalize_layer_impl.hpp" 11 | #include "dll/transform/normalize_layer_desc.hpp" 12 | -------------------------------------------------------------------------------- /include/dll/transform/normalize_layer_desc.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | namespace dll { 11 | 12 | /*! 13 | * \brief Descriptor for layer that normalizes the input data to 14 | * zero-mean and unit-variance 15 | */ 16 | struct normalize_layer_desc { 17 | /*! 18 | * A list of all the parameters of the descriptor 19 | */ 20 | using parameters = cpp::type_list<>; 21 | 22 | /*! The layer type */ 23 | using layer_t = normalize_layer_impl; 24 | 25 | /*! The dynamic layer type */ 26 | using dyn_layer_t = normalize_layer_impl; 27 | }; 28 | 29 | /*! 30 | * \brief Descriptor for layer that normalizes the input data to 31 | * zero-mean and unit-variance 32 | */ 33 | using normalize_layer = typename normalize_layer_desc::layer_t; 34 | 35 | } //end of dll namespace 36 | -------------------------------------------------------------------------------- /include/dll/transform/random_layer.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | #include "dll/transform/random_layer_impl.hpp" 11 | #include "dll/transform/random_layer_desc.hpp" 12 | -------------------------------------------------------------------------------- /include/dll/transform/random_layer_desc.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | namespace dll { 11 | 12 | /*! 13 | * \brief Descriptor for randomization layer 14 | */ 15 | struct random_layer_desc { 16 | /*! 17 | * A list of all the parameters of the descriptor 18 | */ 19 | using parameters = cpp::type_list<>; 20 | 21 | /*! The layer type */ 22 | using layer_t = random_layer_impl; 23 | 24 | /*! The dynamic layer type */ 25 | using dyn_layer_t = random_layer_impl; 26 | }; 27 | 28 | /*! 29 | * \brief Descriptor for randomization layer 30 | */ 31 | using random_layer = typename random_layer_desc::layer_t; 32 | 33 | } //end of dll namespace 34 | -------------------------------------------------------------------------------- /include/dll/transform/rectifier_layer.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | #include "dll/transform/rectifier_method.hpp" 11 | #include "dll/transform/rectifier_layer_impl.hpp" 12 | #include "dll/transform/rectifier_layer_desc.hpp" 13 | -------------------------------------------------------------------------------- /include/dll/transform/rectifier_layer_desc.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | namespace dll { 11 | 12 | /*! 13 | * \brief Descriptor for a rectifier layer (abs) 14 | */ 15 | template 16 | struct rectifier_layer_desc { 17 | static constexpr rectifier_method method = M; ///< The rectifier method to use 18 | 19 | /*! 20 | * A list of all the parameters of the descriptor 21 | */ 22 | using parameters = cpp::type_list<>; 23 | 24 | /*! The layer type */ 25 | using layer_t = rectifier_layer_impl>; 26 | 27 | /*! The dynamic layer type */ 28 | using dyn_layer_t = rectifier_layer_impl>; 29 | }; 30 | 31 | /*! 32 | * \brief Descriptor for a rectifier layer (abs) 33 | */ 34 | template 35 | using rectifier_layer = typename rectifier_layer_desc::layer_t; 36 | 37 | } //end of dll namespace 38 | -------------------------------------------------------------------------------- /include/dll/transform/rectifier_method.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | namespace dll { 11 | 12 | /*! 13 | * \brief List of possible rectifier methods 14 | */ 15 | enum class rectifier_method { 16 | ABS ///< Rectifier with absolute value 17 | }; 18 | 19 | } //end of dll namespace 20 | -------------------------------------------------------------------------------- /include/dll/transform/scale_layer.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | #include "dll/transform/scale_layer_impl.hpp" 11 | #include "dll/transform/scale_layer_desc.hpp" 12 | -------------------------------------------------------------------------------- /include/dll/transform/scale_layer_desc.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | namespace dll { 11 | 12 | /*! 13 | * \brief Descriptor for a scaling layer (multiply by A/B) 14 | */ 15 | template 16 | struct scale_layer_desc { 17 | static constexpr int A = A_T; ///< The scaling multiplicative factor 18 | static constexpr int B = B_T; ///< The scaling dividive factor 19 | 20 | /*! 21 | * A list of all the parameters of the descriptor 22 | */ 23 | using parameters = cpp::type_list<>; 24 | 25 | /*! The layer type */ 26 | using layer_t = scale_layer_impl>; 27 | 28 | /*! The dynamic layer type */ 29 | using dyn_layer_t = scale_layer_impl>; 30 | }; 31 | 32 | /*! 33 | * \brief Descriptor for a scaling layer (multiply by A/B) 34 | */ 35 | template 36 | using scale_layer = typename scale_layer_desc::layer_t; 37 | 38 | } //end of dll namespace 39 | -------------------------------------------------------------------------------- /include/dll/transform/shape_1d_layer.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | #include "dll/transform/dyn_shape_1d_layer.hpp" 11 | 12 | #include "dll/transform/shape_1d_layer_impl.hpp" 13 | #include "dll/transform/shape_1d_layer_desc.hpp" 14 | -------------------------------------------------------------------------------- /include/dll/transform/shape_1d_layer_desc.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | namespace dll { 11 | 12 | /*! 13 | * \brief Descriptor for a 1D shaping layer. 14 | */ 15 | template 16 | struct shape_1d_layer_desc { 17 | /*! 18 | * A list of all the parameters of the descriptor 19 | */ 20 | using parameters = cpp::type_list; 21 | 22 | static constexpr size_t S = S_T; ///< The input size 23 | 24 | /*! The type used to store the weights */ 25 | using weight = detail::get_type_t, Parameters...>; 26 | 27 | /*! 28 | * The layer type 29 | */ 30 | using layer_t = shape_1d_layer_impl>; 31 | 32 | /*! 33 | * The dynamic layer type 34 | */ 35 | using dyn_layer_t = dyn_shape_1d_layer_impl>; 36 | 37 | //Make sure only valid types are passed to the configuration list 38 | static_assert( 39 | detail::is_valid_v, Parameters...>, 40 | "Invalid parameters type for shape_1d_layer_desc"); 41 | }; 42 | 43 | /*! 44 | * \brief Descriptor for a 1D shaping layer. 45 | */ 46 | template 47 | using shape_1d_layer = typename shape_1d_layer_desc::layer_t; 48 | 49 | } //end of dll namespace 50 | -------------------------------------------------------------------------------- /include/dll/transform/shape_3d_layer.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | #include "dll/transform/dyn_shape_3d_layer.hpp" 11 | 12 | #include "dll/transform/shape_3d_layer_impl.hpp" 13 | #include "dll/transform/shape_3d_layer_desc.hpp" 14 | -------------------------------------------------------------------------------- /include/dll/transform/shape_3d_layer_desc.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | namespace dll { 11 | 12 | /*! 13 | * \brief Descriptor for a 3D shaping layer. 14 | */ 15 | template 16 | struct shape_3d_layer_desc { 17 | /*! 18 | * A list of all the parameters of the descriptor 19 | */ 20 | using parameters = cpp::type_list; 21 | 22 | static constexpr size_t C = C_T; ///< The size 23 | static constexpr size_t H = H_T; ///< The size 24 | static constexpr size_t W = W_T; ///< The size 25 | 26 | /*! The type used to store the weights */ 27 | using weight = detail::get_type_t, Parameters...>; 28 | 29 | /*! 30 | * The layer type 31 | */ 32 | using layer_t = shape_3d_layer_impl>; 33 | 34 | /*! 35 | * The dynamic layer type 36 | */ 37 | using dyn_layer_t = dyn_shape_3d_layer_impl>; 38 | 39 | //Make sure only valid types are passed to the configuration list 40 | static_assert( 41 | detail::is_valid_v, Parameters...>, 42 | "Invalid parameters type for shape_3d_layer_desc"); 43 | }; 44 | 45 | /*! 46 | * \brief Descriptor for a 3D shaping layer. 47 | */ 48 | template 49 | using shape_3d_layer = typename shape_3d_layer_desc::layer_t; 50 | 51 | } //end of dll namespace 52 | -------------------------------------------------------------------------------- /include/dll/unit_type.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | namespace dll { 11 | 12 | /*! 13 | * \brief A type of unit inside a RBM 14 | */ 15 | enum class unit_type { 16 | BINARY, ///< Stochastic binary unity 17 | SOFTMAX, ///< Softmax unit (for last layer) 18 | GAUSSIAN, ///< Gaussian unit 19 | RELU, ///< Rectified Linear Unit (ReLU) (Nair and Hinton, 2010) 20 | RELU1, ///< Rectified Linear Unit (ReLU) capped at 1 (Krizhevsky, 2010) 21 | RELU6, ///< Rectified Linear Unit (ReLU) capped at 6 (Krizhevsky,. 2010) 22 | }; 23 | 24 | /*! 25 | * \brief Indicates if the given unit_type is a RELU type 26 | * \param t The type of unit to test 27 | * \return true if the given type is of a ReLU type 28 | */ 29 | constexpr bool is_relu(unit_type t) { 30 | return t == unit_type::RELU || t == unit_type::RELU1 || t == unit_type::RELU6; 31 | } 32 | 33 | /*! 34 | * \brief Return the string representation of a unit type 35 | * \param type The type to transform into string 36 | * \return the string representation of the unit type 37 | */ 38 | inline std::string to_string(unit_type type) { 39 | switch (type) { 40 | case unit_type::BINARY: 41 | return "BINARY"; 42 | case unit_type::SOFTMAX: 43 | return "SOFTMAX"; 44 | case unit_type::GAUSSIAN: 45 | return "GAUSSIAN"; 46 | case unit_type::RELU: 47 | return "RELU"; 48 | case unit_type::RELU1: 49 | return "RELU1"; 50 | case unit_type::RELU6: 51 | return "RELU6"; 52 | } 53 | 54 | cpp_unreachable("Unreachable code"); 55 | 56 | return "UNDEFINED"; 57 | } 58 | 59 | } //end of dll namespace 60 | -------------------------------------------------------------------------------- /include/dll/util/batch_reshape.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | /*! 9 | * \file 10 | * \brief Support for reshaping a sample into a batch-like structure 11 | * using etl::reshape 12 | */ 13 | 14 | #pragma once 15 | 16 | #include "etl/etl.hpp" 17 | 18 | namespace dll { 19 | 20 | /*! 21 | * \brief Reshape the given expression into a batch (1 sample) 22 | * \param expr The expression to reshape 23 | * \return the reshaped expression 24 | */ 25 | template 26 | decltype(auto) batch_reshape(Expr&& expr){ 27 | if constexpr (etl::is_fast) { 28 | if constexpr (etl::dimensions() == 1) { 29 | return etl::reshape<1, etl::dim<0, Expr>()>(expr); 30 | } else if constexpr (etl::dimensions() == 2) { 31 | return etl::reshape<1, etl::dim<0, Expr>(), etl::dim<1, Expr>()>(expr); 32 | } else if constexpr (etl::dimensions() == 3) { 33 | return etl::reshape<1, etl::dim<0, Expr>(), etl::dim<1, Expr>(), etl::dim<2, Expr>()>(expr); 34 | } 35 | } else { 36 | if constexpr (etl::dimensions() == 1) { 37 | return etl::reshape(expr, 1, etl::dim<0>(expr)); 38 | } else if constexpr (etl::dimensions() == 2) { 39 | return etl::reshape(expr, 1, etl::dim<0>(expr), etl::dim<1>(expr)); 40 | } else if constexpr (etl::dimensions() == 3) { 41 | return etl::reshape(expr, 1, etl::dim<0>(expr), etl::dim<1>(expr), etl::dim<2>(expr)); 42 | } 43 | } 44 | 45 | cpp_unreachable("Invalid selection in batch_reshape"); 46 | } 47 | 48 | } //end of dll namespace 49 | -------------------------------------------------------------------------------- /include/dll/util/blas.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | /*! 9 | * \file blas.hpp 10 | * \brief Utility for using BLAS. 11 | */ 12 | 13 | #ifndef DLL_BLAS 14 | #define DLL_BLAS 15 | 16 | namespace dll { 17 | 18 | #ifdef ETL_BLAS_MODE 19 | 20 | inline void blas_ger(size_t n1, size_t n2, float alpha, float* a, float* b, float* c) { 21 | cblas_sger(CblasRowMajor, n1, n2, alpha, a, 1, b, 1, c, n2); 22 | } 23 | 24 | inline void blas_ger(size_t n1, size_t n2, double alpha, double* a, double* b, double* c) { 25 | cblas_dger(CblasRowMajor, n1, n2, alpha, a, 1, b, 1, c, n2); 26 | } 27 | 28 | inline void blas_axpy(size_t n1, float alpha, float* a, float* b) { 29 | cblas_saxpy(n1, alpha, a, 1, b, 1); 30 | } 31 | 32 | inline void blas_axpy(size_t n1, double alpha, double* a, double* b) { 33 | cblas_daxpy(n1, alpha, a, 1, b, 1); 34 | } 35 | 36 | #endif //ETL_BLAS_MODE 37 | 38 | } //end of dll namespace 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /include/dll/util/checks.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | #ifndef NAN_DEBUG 11 | 12 | #define nan_check(value) ((void)0) 13 | #define nan_check_etl(value) ((void)0) 14 | #define nan_check_deep(list) ((void)0) 15 | #define nan_check_deep_deep(list) ((void)0) 16 | #define nan_check_deep_3(l1, l2, l3) ((void)0) 17 | 18 | #else 19 | 20 | #include //for std::isfinite 21 | 22 | #include "cpp_utils/assert.hpp" 23 | 24 | #define nan_check(value) cpp_assert(std::isfinite(((value))), "NaN Verify"); 25 | #define nan_check_etl(value) cpp_assert(((value)).is_finite(), "NaN Verify"); 26 | #define nan_check_deep(list) \ 27 | for (auto& _nan : ((list))) { \ 28 | cpp_assert(std::isfinite(_nan), "NaN Verify"); \ 29 | } 30 | #define nan_check_deep_deep(l) \ 31 | for (auto& _nan_a : ((l))) { \ 32 | for (auto& _nan_b : _nan_a) { \ 33 | cpp_assert(std::isfinite(_nan_b), "NaN Verify"); \ 34 | } \ 35 | } 36 | #define nan_check_deep_3(l1, l2, l3) \ 37 | nan_check_deep(l1); \ 38 | nan_check_deep(l2); \ 39 | nan_check_deep(l3); 40 | 41 | #endif //NDEBUG 42 | -------------------------------------------------------------------------------- /include/dll/util/export.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | /*! 9 | * \file export.hpp 10 | * \brief Export functions to save features 11 | */ 12 | 13 | #pragma once 14 | 15 | #include 16 | #include 17 | #include 18 | 19 | #include "format.hpp" 20 | 21 | namespace dll { 22 | 23 | /*! 24 | * \brief Export the given features to the given file with using DLL format 25 | * \param features The features to be exported 26 | * \param file The file into which to export the features 27 | */ 28 | template 29 | void export_features_dll(const Features& features, const std::string& file) { 30 | std::ofstream os(file); 31 | 32 | std::string comma = ""; 33 | 34 | for (auto& feature : features) { 35 | os << comma << feature; 36 | comma = ";"; 37 | } 38 | 39 | os << '\n'; 40 | } 41 | 42 | } //end of dll namespace 43 | -------------------------------------------------------------------------------- /include/dll/util/format.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | /*! 9 | * \file format.hpp 10 | * \brief Enumeration for the supported input/output formats of the library. 11 | */ 12 | 13 | #pragma once 14 | 15 | namespace dll { 16 | 17 | /*! 18 | * \brief An activation function 19 | */ 20 | enum class format { 21 | DLL ///< Default simple format of the DLL library 22 | }; 23 | 24 | } //end of dll namespace 25 | -------------------------------------------------------------------------------- /include/dll/util/labels.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | namespace dll { 14 | 15 | template 16 | struct fake_label_array { 17 | using value_type = V; 18 | using this_type = fake_label_array; 19 | 20 | value_type value; 21 | 22 | fake_label_array(value_type v) 23 | : value(v) {} 24 | 25 | double operator[](size_t i) const { 26 | if (i == value) { 27 | return 1.0; 28 | } else { 29 | return 0.0; 30 | } 31 | } 32 | }; 33 | 34 | template 35 | std::vector::value_type>>> make_fake(Iterator first, Iterator last) { 36 | std::vector::value_type>>> fake; 37 | fake.reserve(std::distance(first, last)); 38 | 39 | std::for_each(first, last, [&fake](auto v) { 40 | fake.emplace_back(v); 41 | }); 42 | 43 | return fake; 44 | } 45 | 46 | template 47 | etl::dyn_vector make_fake_etl(Label& value, size_t n) { 48 | etl::dyn_vector label(n, 0.0); 49 | 50 | label(value) = 1.0; 51 | 52 | return label; 53 | } 54 | 55 | } //end of dll namespace 56 | -------------------------------------------------------------------------------- /include/dll/utility/dyn_group_layer.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | #include "dll/utility/dyn_group_layer_desc.hpp" 11 | #include "dll/utility/dyn_group_layer_impl.hpp" 12 | -------------------------------------------------------------------------------- /include/dll/utility/dyn_group_layer_desc.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | #include "dll/base_conf.hpp" 11 | #include "dll/util/tmp.hpp" 12 | 13 | namespace dll { 14 | 15 | /*! 16 | * \brief Describe a layer that groups layers together. 17 | */ 18 | template 19 | struct dyn_group_layer_desc { 20 | /*! 21 | * \brief A list of all the parameters of the descriptor 22 | */ 23 | using parameters = cpp::type_list<>; 24 | 25 | /*! The layer type */ 26 | using layer_t = dyn_group_layer_impl>; 27 | 28 | /*! The dynamic layer type */ 29 | using dyn_layer_t = dyn_group_layer_impl>; 30 | 31 | static_assert(sizeof...(Layers) > 0, "A group layer must contain at least one layer"); 32 | }; 33 | 34 | /*! 35 | * \brief Describe a standard group layer. 36 | */ 37 | template 38 | using dyn_group_layer = typename dyn_group_layer_desc::layer_t; 39 | 40 | } //end of dll namespace 41 | -------------------------------------------------------------------------------- /include/dll/utility/dyn_merge_layer.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | #include "dll/utility/dyn_merge_layer_desc.hpp" 11 | #include "dll/utility/dyn_merge_layer_impl.hpp" 12 | -------------------------------------------------------------------------------- /include/dll/utility/dyn_merge_layer_desc.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | #include "dll/base_conf.hpp" 11 | #include "dll/util/tmp.hpp" 12 | 13 | namespace dll { 14 | 15 | /*! 16 | * \brief Describe a layer that merges layers together. 17 | */ 18 | template 19 | struct dyn_merge_layer_desc { 20 | static constexpr size_t D = D_T; 21 | 22 | /*! 23 | * \brief A list of all the parameters of the descriptor 24 | */ 25 | using parameters = cpp::type_list<>; 26 | 27 | /*! The layer type */ 28 | using layer_t = dyn_merge_layer_impl>; 29 | 30 | /*! The dynamic layer type */ 31 | using dyn_layer_t = dyn_merge_layer_impl>; 32 | 33 | static_assert(sizeof...(Layers) > 0, "A merge layer must contain at least one layer"); 34 | }; 35 | 36 | /*! 37 | * \brief Describe a standard merge layer. 38 | */ 39 | template 40 | using dyn_merge_layer = typename dyn_merge_layer_desc::layer_t; 41 | 42 | } //end of dll namespace 43 | -------------------------------------------------------------------------------- /include/dll/utility/group_layer.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | #include "dll/utility/dyn_group_layer.hpp" 11 | 12 | #include "dll/utility/group_layer_desc.hpp" 13 | #include "dll/utility/group_layer_impl.hpp" 14 | -------------------------------------------------------------------------------- /include/dll/utility/group_layer_desc.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | #include "dll/base_conf.hpp" 11 | #include "dll/util/tmp.hpp" 12 | 13 | namespace dll { 14 | 15 | /*! 16 | * \brief Describe a layer that groups layers together. 17 | */ 18 | template 19 | struct group_layer_desc { 20 | /*! 21 | * \brief A list of all the parameters of the descriptor 22 | */ 23 | using parameters = cpp::type_list<>; 24 | 25 | /*! The layer type */ 26 | using layer_t = group_layer_impl>; 27 | 28 | /*! The dynamic layer type */ 29 | using dyn_layer_t = dyn_group_layer_impl>; 30 | 31 | static_assert(sizeof...(Layers) > 0, "A group layer must contain at least one layer"); 32 | }; 33 | 34 | /*! 35 | * \brief Describe a standard group layer. 36 | */ 37 | template 38 | using group_layer = typename group_layer_desc::layer_t; 39 | 40 | } //end of dll namespace 41 | -------------------------------------------------------------------------------- /include/dll/utility/merge_layer.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | #include "dll/utility/dyn_merge_layer.hpp" 11 | 12 | #include "dll/utility/merge_layer_desc.hpp" 13 | #include "dll/utility/merge_layer_impl.hpp" 14 | -------------------------------------------------------------------------------- /include/dll/utility/merge_layer_desc.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | #include "dll/base_conf.hpp" 11 | #include "dll/util/tmp.hpp" 12 | 13 | namespace dll { 14 | 15 | /*! 16 | * \brief Describe a layer that merges layers together. 17 | */ 18 | template 19 | struct merge_layer_desc { 20 | static constexpr size_t D = D_T; 21 | 22 | /*! 23 | * \brief A list of all the parameters of the descriptor 24 | */ 25 | using parameters = cpp::type_list<>; 26 | 27 | /*! The layer type */ 28 | using layer_t = merge_layer_impl>; 29 | 30 | /*! The dynamic layer type */ 31 | using dyn_layer_t = dyn_merge_layer_impl>; 32 | 33 | static_assert(sizeof...(Layers) > 0, "A merge layer must contain at least one layer"); 34 | }; 35 | 36 | /*! 37 | * \brief Describe a standard merge layer. 38 | */ 39 | template 40 | using merge_layer = typename merge_layer_desc::layer_t; 41 | 42 | } //end of dll namespace 43 | -------------------------------------------------------------------------------- /include/dll/version.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #pragma once 9 | 10 | namespace dll { 11 | 12 | /*! 13 | * \brief The current major version number of the library 14 | */ 15 | constexpr size_t version_major = 1; 16 | 17 | /*! 18 | * \brief The current minor version number of the library 19 | */ 20 | constexpr size_t version_minor = 1; 21 | 22 | /*! 23 | * \brief The current revision version number of the library 24 | */ 25 | constexpr size_t version_revision = 0; 26 | 27 | /*! 28 | * \brief The current version number of the library in string form. 29 | */ 30 | constexpr const char* version_str = "1.1"; 31 | 32 | } //end of dll namespace 33 | 34 | /*! 35 | * \brief String representation of the current version of the library. 36 | */ 37 | #define DLL_VERSION_STR "1.1" 38 | 39 | /*! 40 | * \brief The current major version number of the library 41 | */ 42 | #define DLL_VERSION_MAJOR 1 43 | 44 | /*! 45 | * \brief The current minor version number of the library 46 | */ 47 | #define DLL_VERSION_MINOR 1 48 | 49 | /*! 50 | * \brief The current revision version number of the library 51 | */ 52 | #define DLL_VERSION_REVISION 0 53 | -------------------------------------------------------------------------------- /logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wichtounet/dll/549353493fb3177503a36259c40d25a3792c8daa/logo.png -------------------------------------------------------------------------------- /logo_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wichtounet/dll/549353493fb3177503a36259c40d25a3792c8daa/logo_small.png -------------------------------------------------------------------------------- /processor/include/parse_utils.hpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #include "cpp_utils/string.hpp" 15 | 16 | #include "dll/processor/processor.hpp" 17 | 18 | namespace dllp { 19 | 20 | bool extract_value(const std::string& line, const std::string& search, std::string& value); 21 | bool starts_with(const std::string& str, const std::string& search); 22 | std::string extract_value(const std::string& str, const std::string& search); 23 | 24 | bool valid_unit(const std::string& unit); 25 | bool valid_trainer(const std::string& unit); 26 | bool valid_ft_trainer(const std::string& unit); 27 | bool valid_activation(const std::string& unit); 28 | bool valid_sparsity(const std::string& unit); 29 | 30 | std::string unit_type(const std::string& unit); 31 | std::string activation_function(const std::string& unit); 32 | std::string decay_to_str(const std::string& decay); 33 | std::string sparsity_to_str(const std::string& decay); 34 | 35 | std::vector read_lines(const std::string& source_file); 36 | 37 | } //end of namespace dllp 38 | -------------------------------------------------------------------------------- /processor/samples/conv_mnist_scale.conf: -------------------------------------------------------------------------------- 1 | include: /home/wichtounet/dev/dll/processor/samples/inc_mnist_scale.conf 2 | 3 | network: 4 | conv: 5 | channels: 1 6 | v1: 28 7 | v2: 28 8 | filters: 10 9 | w1: 5 10 | w2: 5 11 | activation: sigmoid 12 | conv: 13 | filters: 6 14 | w1: 5 15 | w2: 5 16 | activation: sigmoid 17 | dense: 18 | hidden: 500 19 | activation: sigmoid 20 | dense: 21 | hidden: 10 22 | activation: softmax 23 | 24 | options: 25 | training: 26 | epochs: 15 27 | batch: 10 28 | learning_rate: 0.05 29 | 30 | weights: 31 | file: dbn.dat 32 | -------------------------------------------------------------------------------- /processor/samples/dbn_mnist.conf: -------------------------------------------------------------------------------- 1 | data: 2 | pretraining: 3 | limit: 500 4 | samples: 5 | source: /home/wichtounet/dev/mnist/train-images-idx3-ubyte 6 | reader: mnist 7 | binarize: true 8 | 9 | training: 10 | limit: 500 11 | samples: 12 | source: /home/wichtounet/dev/mnist/train-images-idx3-ubyte 13 | reader: mnist 14 | binarize: true 15 | labels: 16 | source: /home/wichtounet/dev/mnist/train-labels-idx1-ubyte 17 | reader: mnist 18 | 19 | testing: 20 | samples: 21 | source: /home/wichtounet/dev/mnist/t10k-images-idx3-ubyte 22 | reader: mnist 23 | binarize: true 24 | labels: 25 | source: /home/wichtounet/dev/mnist/t10k-labels-idx1-ubyte 26 | reader: mnist 27 | 28 | network: 29 | rbm: 30 | visible: 784 31 | hidden: 1000 32 | batch: 20 33 | momentum: 0.8 34 | learning_rate: 0.09 35 | rbm: 36 | hidden: 250 37 | batch: 20 38 | rbm: 39 | hidden: 10 40 | visible_unit: binary 41 | hidden_unit: softmax 42 | batch: 20 43 | 44 | options: 45 | pretraining: 46 | epochs: 10 47 | 48 | training: 49 | epochs: 10 50 | learning_rate: 0.05 51 | momentum: 0.8 52 | batch: 10 53 | 54 | weights: 55 | file: dbn.dat 56 | -------------------------------------------------------------------------------- /processor/samples/dbn_mnist_real.conf: -------------------------------------------------------------------------------- 1 | data: 2 | pretraining: 3 | limit: 500 4 | samples: 5 | source: /home/wichtounet/dev/mnist/train-images-idx3-ubyte 6 | reader: mnist 7 | normalize: true 8 | 9 | training: 10 | limit: 500 11 | samples: 12 | source: /home/wichtounet/dev/mnist/train-images-idx3-ubyte 13 | reader: mnist 14 | normalize: true 15 | labels: 16 | source: /home/wichtounet/dev/mnist/train-labels-idx1-ubyte 17 | reader: mnist 18 | 19 | testing: 20 | samples: 21 | source: /home/wichtounet/dev/mnist/t10k-images-idx3-ubyte 22 | reader: mnist 23 | normalize: true 24 | labels: 25 | source: /home/wichtounet/dev/mnist/t10k-labels-idx1-ubyte 26 | reader: mnist 27 | 28 | network: 29 | rbm: 30 | visible: 784 31 | hidden: 1000 32 | batch: 20 33 | visible_unit: gaussian 34 | rbm: 35 | hidden: 350 36 | batch: 20 37 | rbm: 38 | hidden: 10 39 | hidden_unit: softmax 40 | batch: 20 41 | 42 | options: 43 | pretraining: 44 | epochs: 10 45 | 46 | training: 47 | epochs: 10 48 | batch: 20 49 | 50 | weights: 51 | file: dbn.dat 52 | -------------------------------------------------------------------------------- /processor/samples/dbn_mnist_scale.conf: -------------------------------------------------------------------------------- 1 | data: 2 | pretraining: 3 | limit: 500 4 | samples: 5 | source: /home/wichtounet/dev/mnist/train-images-idx3-ubyte 6 | reader: mnist 7 | scale: 0.00390625 8 | 9 | training: 10 | limit: 500 11 | samples: 12 | source: /home/wichtounet/dev/mnist/train-images-idx3-ubyte 13 | reader: mnist 14 | scale: 0.00390625 15 | labels: 16 | source: /home/wichtounet/dev/mnist/train-labels-idx1-ubyte 17 | reader: mnist 18 | 19 | testing: 20 | samples: 21 | source: /home/wichtounet/dev/mnist/t10k-images-idx3-ubyte 22 | reader: mnist 23 | scale: 0.00390625 24 | labels: 25 | source: /home/wichtounet/dev/mnist/t10k-labels-idx1-ubyte 26 | reader: mnist 27 | 28 | network: 29 | rbm: 30 | visible: 784 31 | hidden: 1000 32 | batch: 20 33 | visible_unit: gaussian 34 | rbm: 35 | hidden: 350 36 | batch: 20 37 | rbm: 38 | hidden: 10 39 | hidden_unit: softmax 40 | batch: 20 41 | 42 | options: 43 | pretraining: 44 | epochs: 10 45 | 46 | training: 47 | epochs: 10 48 | batch: 20 49 | 50 | weights: 51 | file: dbn.dat 52 | -------------------------------------------------------------------------------- /processor/samples/dense_mnist_scale.conf: -------------------------------------------------------------------------------- 1 | data: 2 | training: 3 | limit: 500 4 | samples: 5 | source: /home/wichtounet/dev/mnist/train-images-idx3-ubyte 6 | reader: mnist 7 | scale: 0.00390625 8 | labels: 9 | source: /home/wichtounet/dev/mnist/train-labels-idx1-ubyte 10 | reader: mnist 11 | 12 | testing: 13 | samples: 14 | source: /home/wichtounet/dev/mnist/t10k-images-idx3-ubyte 15 | reader: mnist 16 | scale: 0.00390625 17 | labels: 18 | source: /home/wichtounet/dev/mnist/t10k-labels-idx1-ubyte 19 | reader: mnist 20 | 21 | network: 22 | dense: 23 | visible: 784 24 | hidden: 1000 25 | activation: sigmoid 26 | dense: 27 | hidden: 350 28 | dense: 29 | hidden: 10 30 | activation: softmax 31 | 32 | options: 33 | training: 34 | epochs: 15 35 | batch: 20 36 | learning_rate: 0.01 37 | momentum: 0.9 38 | weight_decay: l2 39 | l2_weight_cost: 0.0002 40 | 41 | weights: 42 | file: dbn.dat 43 | -------------------------------------------------------------------------------- /processor/samples/inc_mnist_scale.conf: -------------------------------------------------------------------------------- 1 | data: 2 | training: 3 | limit: 500 4 | samples: 5 | source: /home/wichtounet/dev/mnist/train-images-idx3-ubyte 6 | reader: mnist 7 | scale: 0.00390625 8 | labels: 9 | source: /home/wichtounet/dev/mnist/train-labels-idx1-ubyte 10 | reader: mnist 11 | 12 | testing: 13 | samples: 14 | source: /home/wichtounet/dev/mnist/t10k-images-idx3-ubyte 15 | reader: mnist 16 | scale: 0.00390625 17 | labels: 18 | source: /home/wichtounet/dev/mnist/t10k-labels-idx1-ubyte 19 | reader: mnist 20 | -------------------------------------------------------------------------------- /sonar-project.properties: -------------------------------------------------------------------------------- 1 | sonar.projectKey=dll 2 | sonar.projectName=dll 3 | sonar.projectVersion=1.1 4 | 5 | sonar.sourceEncoding=UTF-8 6 | sonar.sources=include,test,processor,view 7 | sonar.language=c++ 8 | 9 | # Reports file for sonar-cxx 10 | sonar.cxx.cppcheck.reportPath=cppcheck_report.xml 11 | # sonar.cxx.coverage.reportPath=coverage_report.xml 12 | sonar.cxx.xunit.reportPath=catch_report.xml 13 | 14 | # Configure headers 15 | sonar.cxx.suffixes.headers=.hpp,.inl 16 | sonar.cxx.includeDirectories=include,test/include,processor/include,etl/lib/include,etl/include,mnist/include,Catch/include,nice_svm/include,/usr/include 17 | 18 | # Exclude some things from coverage and duplications 19 | sonar.cpd.exclusions=test/src/*,test/include/*,workbench/src/*,view/src/* 20 | 21 | # Declare list of ignore filters 22 | sonar.issue.ignore.multicriteria=notestunit,notestmisc,notestperf,noview,nodocproc 23 | 24 | # Ignore all issues on test unit sources 25 | sonar.issue.ignore.multicriteria.notestunit.ruleKey=* 26 | sonar.issue.ignore.multicriteria.notestunit.resourceKey=test/src/unit/* 27 | 28 | # Ignore all issues on test perf sources 29 | sonar.issue.ignore.multicriteria.notestperf.ruleKey=* 30 | sonar.issue.ignore.multicriteria.notestperf.resourceKey=test/src/perf/* 31 | 32 | # Ignore all issues on test misc sources 33 | sonar.issue.ignore.multicriteria.notestmisc.ruleKey=* 34 | sonar.issue.ignore.multicriteria.notestmisc.resourceKey=test/src/misc/* 35 | 36 | # Ignore all issues on benchmark sources 37 | sonar.issue.ignore.multicriteria.noview.ruleKey=* 38 | sonar.issue.ignore.multicriteria.noview.resourceKey=view/src/* 39 | 40 | # All documentation issues on the include of the processor 41 | sonar.issue.ignore.multicriteria.nodocproc.ruleKey=cxx:UndocumentedApi 42 | sonar.issue.ignore.multicriteria.nodocproc.resourceKey=include/dll/processor/processor.hpp 43 | 44 | # Activate workarounds in source code for sonar-cxx 45 | sonar.cxx.defines=SONAR_ANALYSIS true 46 | -------------------------------------------------------------------------------- /test/processor/cdbn_1.conf: -------------------------------------------------------------------------------- 1 | include: test/processor/unit_mnist_binary.conf 2 | 3 | network: 4 | crbm: 5 | channels: 1 6 | v1: 28 7 | v2: 28 8 | filters: 8 9 | w1: 9 10 | w2: 9 11 | weight_decay: l1 12 | l1_weight_cost: 0.002 13 | 14 | crbm: 15 | channels: 8 16 | v1: 20 17 | v2: 20 18 | filters: 8 19 | w1: 5 20 | w2: 5 21 | weight_decay: l1 22 | l1_weight_cost: 0.002 23 | 24 | options: 25 | pretraining: 26 | epochs: 25 27 | -------------------------------------------------------------------------------- /test/processor/cdbn_2.conf: -------------------------------------------------------------------------------- 1 | include: test/processor/unit_mnist_binary.conf 2 | 3 | network: 4 | crbm: 5 | channels: 1 6 | v1: 28 7 | v2: 28 8 | filters: 10 9 | w1: 9 10 | w2: 9 11 | learning_rate: 0.0005 12 | weight_decay: l1 13 | l1_weight_cost: 0.002 14 | sparsity: lee 15 | pbias: 0.001 16 | pbias_lambda: 50 17 | 18 | crbm: 19 | channels: 10 20 | v1: 20 21 | v2: 20 22 | filters: 10 23 | w1: 5 24 | w2: 5 25 | learning_rate: 0.0005 26 | weight_decay: l1 27 | l1_weight_cost: 0.002 28 | sparsity: lee 29 | pbias: 0.001 30 | pbias_lambda: 50 31 | 32 | options: 33 | pretraining: 34 | epochs: 25 35 | -------------------------------------------------------------------------------- /test/processor/conv_pool_sgd_1.conf: -------------------------------------------------------------------------------- 1 | include: test/processor/unit_mnist.conf 2 | 3 | network: 4 | conv: 5 | channels: 1 6 | v1: 28 7 | v2: 28 8 | filters: 6 9 | w1: 5 10 | w2: 5 11 | activation: relu 12 | 13 | mp: 14 | c1: 1 15 | c2: 2 16 | c3: 2 17 | 18 | conv: 19 | filters: 6 20 | w1: 3 21 | w2: 3 22 | activation: relu 23 | 24 | mp: 25 | c1: 1 26 | c2: 2 27 | c3: 2 28 | 29 | dense: 30 | hidden: 250 31 | activation: relu 32 | 33 | dense: 34 | hidden: 10 35 | activation: softmax 36 | 37 | options: 38 | training: 39 | epochs: 40 40 | batch: 10 41 | learning_rate: 0.05 42 | weight_decay: l1l2 43 | l2_weight_cost: 0.0002 44 | l1_weight_cost: 0.0003 45 | -------------------------------------------------------------------------------- /test/processor/conv_pool_sgd_2.conf: -------------------------------------------------------------------------------- 1 | include: test/processor/unit_mnist.conf 2 | 3 | network: 4 | conv: 5 | channels: 1 6 | v1: 28 7 | v2: 28 8 | filters: 6 9 | w1: 5 10 | w2: 5 11 | activation: identity 12 | 13 | function: 14 | activation: relu 15 | 16 | mp: 17 | c1: 1 18 | c2: 2 19 | c3: 2 20 | 21 | dense: 22 | hidden: 250 23 | activation: identity 24 | 25 | function: 26 | activation: relu 27 | 28 | dense: 29 | hidden: 10 30 | activation: identity 31 | 32 | function: 33 | activation: softmax 34 | 35 | options: 36 | training: 37 | epochs: 30 38 | batch: 10 39 | learning_rate: 0.05 40 | weight_decay: l1l2 41 | l2_weight_cost: 0.0002 42 | l1_weight_cost: 0.0003 43 | -------------------------------------------------------------------------------- /test/processor/conv_pool_sgd_2_verbose.conf: -------------------------------------------------------------------------------- 1 | include: test/processor/unit_mnist.conf 2 | 3 | network: 4 | conv: 5 | channels: 1 6 | v1: 28 7 | v2: 28 8 | filters: 6 9 | w1: 5 10 | w2: 5 11 | activation: identity 12 | 13 | function: 14 | activation: relu 15 | 16 | mp: 17 | c1: 1 18 | c2: 2 19 | c3: 2 20 | 21 | dense: 22 | hidden: 250 23 | activation: identity 24 | 25 | function: 26 | activation: relu 27 | 28 | dense: 29 | hidden: 10 30 | activation: identity 31 | 32 | function: 33 | activation: softmax 34 | 35 | options: 36 | training: 37 | epochs: 30 38 | batch: 10 39 | learning_rate: 0.05 40 | weight_decay: l1l2 41 | l2_weight_cost: 0.0002 42 | l1_weight_cost: 0.0003 43 | verbose: true 44 | -------------------------------------------------------------------------------- /test/processor/conv_sgd_1.conf: -------------------------------------------------------------------------------- 1 | include: test/processor/unit_mnist_binary.conf 2 | 3 | network: 4 | conv: 5 | channels: 1 6 | v1: 28 7 | v2: 28 8 | filters: 10 9 | w1: 5 10 | w2: 5 11 | 12 | dense: 13 | hidden: 10 14 | 15 | options: 16 | training: 17 | epochs: 100 18 | batch: 10 19 | learning_rate: 0.03 20 | -------------------------------------------------------------------------------- /test/processor/conv_sgd_2.conf: -------------------------------------------------------------------------------- 1 | include: test/processor/unit_mnist_binary.conf 2 | 3 | network: 4 | conv: 5 | channels: 1 6 | v1: 28 7 | v2: 28 8 | filters: 10 9 | w1: 5 10 | w2: 5 11 | 12 | dense: 13 | hidden: 10 14 | activation: softmax 15 | 16 | options: 17 | training: 18 | epochs: 100 19 | batch: 10 20 | learning_rate: 0.03 21 | momentum: 0.9 22 | -------------------------------------------------------------------------------- /test/processor/conv_sgd_3.conf: -------------------------------------------------------------------------------- 1 | include: test/processor/unit_mnist.conf 2 | 3 | network: 4 | conv: 5 | channels: 1 6 | v1: 28 7 | v2: 28 8 | filters: 10 9 | w1: 5 10 | w2: 5 11 | activation: tanh 12 | 13 | dense: 14 | hidden: 10 15 | activation: tanh 16 | 17 | options: 18 | training: 19 | epochs: 100 20 | batch: 20 21 | learning_rate: 0.05 22 | -------------------------------------------------------------------------------- /test/processor/conv_sgd_4.conf: -------------------------------------------------------------------------------- 1 | include: test/processor/unit_mnist.conf 2 | 3 | network: 4 | conv: 5 | channels: 1 6 | v1: 28 7 | v2: 28 8 | filters: 10 9 | w1: 5 10 | w2: 5 11 | activation: relu 12 | 13 | dense: 14 | hidden: 10 15 | activation: softmax 16 | 17 | options: 18 | training: 19 | epochs: 100 20 | batch: 10 21 | learning_rate: 0.05 22 | -------------------------------------------------------------------------------- /test/processor/conv_sgd_5.conf: -------------------------------------------------------------------------------- 1 | include: test/processor/unit_mnist.conf 2 | 3 | network: 4 | conv: 5 | channels: 1 6 | v1: 28 7 | v2: 28 8 | filters: 10 9 | w1: 5 10 | w2: 5 11 | activation: relu 12 | 13 | dense: 14 | hidden: 250 15 | activation: relu 16 | 17 | dense: 18 | hidden: 10 19 | activation: softmax 20 | 21 | options: 22 | training: 23 | epochs: 100 24 | batch: 10 25 | learning_rate: 0.05 26 | -------------------------------------------------------------------------------- /test/processor/conv_sgd_6.conf: -------------------------------------------------------------------------------- 1 | include: test/processor/unit_mnist.conf 2 | 3 | network: 4 | conv: 5 | channels: 1 6 | v1: 28 7 | v2: 28 8 | filters: 10 9 | w1: 5 10 | w2: 5 11 | activation: relu 12 | 13 | conv: 14 | filters: 6 15 | w1: 3 16 | w2: 3 17 | activation: relu 18 | 19 | dense: 20 | hidden: 250 21 | activation: relu 22 | 23 | dense: 24 | hidden: 10 25 | activation: softmax 26 | 27 | options: 28 | training: 29 | epochs: 100 30 | batch: 10 31 | learning_rate: 0.05 32 | weight_decay: l1l2 33 | l2_weight_cost: 0.0002 34 | l1_weight_cost: 0.0003 35 | -------------------------------------------------------------------------------- /test/processor/crbm_1.conf: -------------------------------------------------------------------------------- 1 | include: test/processor/unit_mnist_binary.conf 2 | 3 | network: 4 | crbm: 5 | channels: 1 6 | v1: 28 7 | v2: 28 8 | filters: 10 9 | w1: 5 10 | w2: 5 11 | 12 | options: 13 | pretraining: 14 | epochs: 25 15 | -------------------------------------------------------------------------------- /test/processor/crbm_2.conf: -------------------------------------------------------------------------------- 1 | include: test/processor/unit_mnist_binary.conf 2 | 3 | network: 4 | crbm: 5 | channels: 1 6 | v1: 28 7 | v2: 28 8 | filters: 10 9 | w1: 5 10 | w2: 5 11 | weight_decay: l1 12 | l1_weight_cost: 0.002 13 | 14 | options: 15 | pretraining: 16 | epochs: 25 17 | -------------------------------------------------------------------------------- /test/processor/crbm_mp_1.conf: -------------------------------------------------------------------------------- 1 | include: test/processor/unit_mnist_binary.conf 2 | 3 | network: 4 | crbm_mp: 5 | channels: 1 6 | v1: 28 7 | v2: 28 8 | filters: 10 9 | w1: 5 10 | w2: 5 11 | pool: 2 12 | learning_rate: 0.005 13 | 14 | options: 15 | pretraining: 16 | epochs: 50 17 | -------------------------------------------------------------------------------- /test/processor/dbn_cg_1.conf: -------------------------------------------------------------------------------- 1 | include: test/processor/unit_mnist_binary.conf 2 | 3 | network: 4 | rbm: 5 | visible: 784 6 | hidden: 150 7 | batch: 10 8 | rbm: 9 | hidden: 250 10 | batch: 10 11 | rbm: 12 | hidden: 10 13 | hidden_unit: softmax 14 | batch: 10 15 | 16 | options: 17 | pretraining: 18 | epochs: 25 19 | 20 | training: 21 | trainer: cg 22 | epochs: 50 23 | batch: 10 24 | -------------------------------------------------------------------------------- /test/processor/dbn_sgd_1.conf: -------------------------------------------------------------------------------- 1 | include: test/processor/unit_mnist_binary.conf 2 | 3 | network: 4 | rbm: 5 | visible: 784 6 | hidden: 150 7 | batch: 10 8 | rbm: 9 | hidden: 250 10 | batch: 10 11 | rbm: 12 | hidden: 10 13 | hidden_unit: softmax 14 | batch: 10 15 | 16 | options: 17 | pretraining: 18 | epochs: 25 19 | 20 | training: 21 | epochs: 50 22 | batch: 10 23 | learning_rate: 0.03 24 | -------------------------------------------------------------------------------- /test/processor/dbn_sgd_2.conf: -------------------------------------------------------------------------------- 1 | include: test/processor/unit_mnist_text_binary.conf 2 | 3 | network: 4 | rbm: 5 | visible: 784 6 | hidden: 150 7 | batch: 10 8 | rbm: 9 | hidden: 250 10 | batch: 10 11 | rbm: 12 | hidden: 10 13 | hidden_unit: softmax 14 | batch: 10 15 | 16 | options: 17 | pretraining: 18 | epochs: 25 19 | 20 | training: 21 | epochs: 50 22 | batch: 10 23 | learning_rate: 0.03 24 | -------------------------------------------------------------------------------- /test/processor/dbn_sgd_3.conf: -------------------------------------------------------------------------------- 1 | include: test/processor/unit_mnist_text_binary.conf 2 | 3 | network: 4 | rbm: 5 | visible: 784 6 | hidden: 150 7 | batch: 10 8 | rbm: 9 | hidden: 250 10 | batch: 10 11 | rbm: 12 | hidden: 10 13 | hidden_unit: softmax 14 | batch: 10 15 | 16 | options: 17 | general: 18 | batch_mode: true 19 | big_batch: 5 20 | 21 | pretraining: 22 | epochs: 25 23 | 24 | training: 25 | epochs: 50 26 | batch: 10 27 | learning_rate: 0.03 28 | -------------------------------------------------------------------------------- /test/processor/dense_sgd_1.conf: -------------------------------------------------------------------------------- 1 | include: test/processor/unit_mnist_normalized.conf 2 | 3 | action: train 4 | action: test 5 | 6 | network: 7 | dense: 8 | visible: 784 9 | hidden: 150 10 | dense: 11 | hidden: 10 12 | 13 | options: 14 | training: 15 | epochs: 50 16 | batch: 10 17 | learning_rate: 0.03 18 | -------------------------------------------------------------------------------- /test/processor/dense_sgd_2.conf: -------------------------------------------------------------------------------- 1 | include: test/processor/unit_mnist_binary.conf 2 | 3 | network: 4 | dense: 5 | visible: 784 6 | hidden: 150 7 | dense: 8 | hidden: 10 9 | 10 | options: 11 | training: 12 | epochs: 50 13 | batch: 10 14 | learning_rate: 0.03 15 | weight_decay: l1l2 16 | l1_weight_cost: 0.0002 17 | l2_weight_cost: 0.0003 18 | -------------------------------------------------------------------------------- /test/processor/rbm_1.conf: -------------------------------------------------------------------------------- 1 | include: test/processor/unit_mnist_binary.conf 2 | 3 | network: 4 | rbm: 5 | visible: 784 6 | hidden: 150 7 | 8 | options: 9 | pretraining: 10 | epochs: 25 11 | -------------------------------------------------------------------------------- /test/processor/rbm_2.conf: -------------------------------------------------------------------------------- 1 | include: test/processor/unit_mnist_binary.conf 2 | 3 | network: 4 | rbm: 5 | visible: 784 6 | hidden: 150 7 | weight_decay: l2 8 | l2_weight_cost: 0.0005 9 | 10 | options: 11 | pretraining: 12 | epochs: 25 13 | -------------------------------------------------------------------------------- /test/processor/rbm_3.conf: -------------------------------------------------------------------------------- 1 | include: test/processor/unit_mnist_normalized.conf 2 | 3 | network: 4 | rbm: 5 | visible: 784 6 | hidden: 200 7 | momentum: 0.9 8 | learning_rate: 0.005 9 | visible_unit: gaussian 10 | batch: 25 11 | 12 | options: 13 | pretraining: 14 | epochs: 100 15 | -------------------------------------------------------------------------------- /test/processor/rbm_4.conf: -------------------------------------------------------------------------------- 1 | include: test/processor/unit_mnist_binary.conf 2 | 3 | network: 4 | rbm: 5 | visible: 784 6 | hidden: 150 7 | batch: 10 8 | 9 | options: 10 | pretraining: 11 | epochs: 50 12 | -------------------------------------------------------------------------------- /test/processor/rbm_5.conf: -------------------------------------------------------------------------------- 1 | include: test/processor/unit_mnist_binary.conf 2 | 3 | network: 4 | rbm: 5 | visible: 784 6 | hidden: 150 7 | shuffle: true 8 | batch: 10 9 | 10 | options: 11 | pretraining: 12 | epochs: 50 13 | -------------------------------------------------------------------------------- /test/processor/rbm_6.conf: -------------------------------------------------------------------------------- 1 | include: test/processor/unit_mnist_binary.conf 2 | 3 | network: 4 | rbm: 5 | visible: 784 6 | hidden: 150 7 | shuffle: true 8 | trainer: pcd 9 | momentum: 0.9 10 | batch: 10 11 | 12 | options: 13 | pretraining: 14 | epochs: 100 15 | -------------------------------------------------------------------------------- /test/processor/rbm_7.conf: -------------------------------------------------------------------------------- 1 | include: test/processor/unit_mnist_binary.conf 2 | 3 | network: 4 | rbm: 5 | visible: 784 6 | hidden: 150 7 | batch: 10 8 | sparsity: local 9 | sparsity_target: 0.1 10 | momentum: 0.9 11 | 12 | options: 13 | pretraining: 14 | epochs: 50 15 | -------------------------------------------------------------------------------- /test/processor/rbm_8.conf: -------------------------------------------------------------------------------- 1 | include: test/processor/unit_mnist_binary.conf 2 | 3 | network: 4 | rbm: 5 | visible: 784 6 | hidden: 150 7 | batch: 10 8 | sparsity: global 9 | sparsity_target: 0.1 10 | momentum: 0.9 11 | 12 | options: 13 | pretraining: 14 | epochs: 50 15 | -------------------------------------------------------------------------------- /test/processor/rbm_9.conf: -------------------------------------------------------------------------------- 1 | include: test/processor/unit_mnist_noisy.conf 2 | 3 | network: 4 | rbm: 5 | visible: 784 6 | hidden: 300 7 | batch: 10 8 | momentum: 0.9 9 | visible_unit: gaussian 10 | learning_rate: 0.003 11 | 12 | options: 13 | pretraining: 14 | epochs: 50 15 | denoising: true 16 | -------------------------------------------------------------------------------- /test/processor/unit_mnist.conf: -------------------------------------------------------------------------------- 1 | data: 2 | training: 3 | limit: 350 4 | samples: 5 | source: /home/wichtounet/dev/mnist/train-images-idx3-ubyte 6 | reader: mnist 7 | scale: 0.00390625 8 | labels: 9 | source: /home/wichtounet/dev/mnist/train-labels-idx1-ubyte 10 | reader: mnist 11 | 12 | testing: 13 | samples: 14 | source: /home/wichtounet/dev/mnist/t10k-images-idx3-ubyte 15 | reader: mnist 16 | scale: 0.00390625 17 | labels: 18 | source: /home/wichtounet/dev/mnist/t10k-labels-idx1-ubyte 19 | reader: mnist 20 | -------------------------------------------------------------------------------- /test/processor/unit_mnist_binary.conf: -------------------------------------------------------------------------------- 1 | data: 2 | pretraining: 3 | limit: 350 4 | samples: 5 | source: mnist/train-images-idx3-ubyte 6 | reader: mnist 7 | binarize: true 8 | labels: 9 | source: mnist/train-labels-idx1-ubyte 10 | reader: mnist 11 | 12 | training: 13 | limit: 350 14 | samples: 15 | source: mnist/train-images-idx3-ubyte 16 | reader: mnist 17 | binarize: true 18 | labels: 19 | source: mnist/train-labels-idx1-ubyte 20 | reader: mnist 21 | 22 | testing: 23 | samples: 24 | source: mnist/t10k-images-idx3-ubyte 25 | reader: mnist 26 | binarize: true 27 | labels: 28 | source: mnist/t10k-labels-idx1-ubyte 29 | reader: mnist 30 | -------------------------------------------------------------------------------- /test/processor/unit_mnist_noisy.conf: -------------------------------------------------------------------------------- 1 | data: 2 | pretraining: 3 | limit: 350 4 | samples: 5 | source: /home/wichtounet/dev/mnist/train-images-idx3-ubyte 6 | reader: mnist 7 | normal_noise: 0.5 8 | labels: 9 | source: /home/wichtounet/dev/mnist/train-labels-idx1-ubyte 10 | reader: mnist 11 | 12 | pretraining_clean: 13 | limit: 350 14 | samples: 15 | source: /home/wichtounet/dev/mnist/train-images-idx3-ubyte 16 | reader: mnist 17 | normalize: true 18 | labels: 19 | source: /home/wichtounet/dev/mnist/train-labels-idx1-ubyte 20 | reader: mnist 21 | 22 | training: 23 | limit: 350 24 | samples: 25 | source: /home/wichtounet/dev/mnist/train-images-idx3-ubyte 26 | reader: mnist 27 | normalize: true 28 | labels: 29 | source: /home/wichtounet/dev/mnist/train-labels-idx1-ubyte 30 | reader: mnist 31 | 32 | testing: 33 | samples: 34 | source: /home/wichtounet/dev/mnist/t10k-images-idx3-ubyte 35 | reader: mnist 36 | normalize: true 37 | labels: 38 | source: /home/wichtounet/dev/mnist/t10k-labels-idx1-ubyte 39 | reader: mnist 40 | -------------------------------------------------------------------------------- /test/processor/unit_mnist_normalized.conf: -------------------------------------------------------------------------------- 1 | data: 2 | pretraining: 3 | limit: 350 4 | samples: 5 | source: /home/wichtounet/dev/mnist/train-images-idx3-ubyte 6 | reader: mnist 7 | normalize: true 8 | labels: 9 | source: /home/wichtounet/dev/mnist/train-labels-idx1-ubyte 10 | reader: mnist 11 | 12 | training: 13 | limit: 350 14 | samples: 15 | source: /home/wichtounet/dev/mnist/train-images-idx3-ubyte 16 | reader: mnist 17 | normalize: true 18 | labels: 19 | source: /home/wichtounet/dev/mnist/train-labels-idx1-ubyte 20 | reader: mnist 21 | 22 | testing: 23 | samples: 24 | source: /home/wichtounet/dev/mnist/t10k-images-idx3-ubyte 25 | reader: mnist 26 | normalize: true 27 | labels: 28 | source: /home/wichtounet/dev/mnist/t10k-labels-idx1-ubyte 29 | reader: mnist 30 | -------------------------------------------------------------------------------- /test/processor/unit_mnist_raw.conf: -------------------------------------------------------------------------------- 1 | data: 2 | training: 3 | limit: 350 4 | samples: 5 | source: /home/wichtounet/dev/mnist/train-images-idx3-ubyte 6 | reader: mnist 7 | labels: 8 | source: /home/wichtounet/dev/mnist/train-labels-idx1-ubyte 9 | reader: mnist 10 | 11 | testing: 12 | samples: 13 | source: /home/wichtounet/dev/mnist/t10k-images-idx3-ubyte 14 | reader: mnist 15 | labels: 16 | source: /home/wichtounet/dev/mnist/t10k-labels-idx1-ubyte 17 | reader: mnist 18 | -------------------------------------------------------------------------------- /test/processor/unit_mnist_text_binary.conf: -------------------------------------------------------------------------------- 1 | data: 2 | pretraining: 3 | limit: 350 4 | samples: 5 | source: /home/wichtounet/datasets/mnist_text/train/images 6 | reader: text 7 | binarize: true 8 | labels: 9 | source: /home/wichtounet/datasets/mnist_text/train/labels 10 | reader: text 11 | 12 | training: 13 | limit: 350 14 | samples: 15 | source: /home/wichtounet/datasets/mnist_text/train/images 16 | reader: text 17 | binarize: true 18 | labels: 19 | source: /home/wichtounet/datasets/mnist_text/train/labels 20 | reader: text 21 | 22 | testing: 23 | samples: 24 | source: /home/wichtounet/datasets/mnist_text/test/images 25 | reader: text 26 | binarize: true 27 | labels: 28 | source: /home/wichtounet/datasets/mnist_text/test/labels 29 | reader: text 30 | -------------------------------------------------------------------------------- /test/src/misc/cdbn_sgd_1.cpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #include "dll_test.hpp" 9 | 10 | #include "dll/rbm/conv_rbm.hpp" 11 | #include "dll/rbm/rbm.hpp" 12 | #include "dll/dbn.hpp" 13 | 14 | #include "mnist/mnist_reader.hpp" 15 | #include "mnist/mnist_utils.hpp" 16 | 17 | DLL_TEST_CASE("cdbn/sgd/1", "[dbn][mnist][sgd]") { 18 | typedef dll::dbn_desc< 19 | dll::dbn_layers< 20 | dll::conv_rbm_square_desc<1, 28, 10, 17, dll::momentum, dll::batch_size<10>, dll::weight_type>::layer_t, 21 | dll::rbm_desc<12 * 12 * 10, 10, dll::momentum, dll::batch_size<10>, dll::hidden>::layer_t>, 22 | dll::trainer, dll::batch_size<10>>::dbn_t dbn_t; 23 | 24 | auto dataset = mnist::read_dataset_direct>(500); 25 | REQUIRE(!dataset.training_images.empty()); 26 | 27 | mnist::binarize_dataset(dataset); 28 | 29 | auto dbn = std::make_unique(); 30 | 31 | dbn->pretrain(dataset.training_images, 20); 32 | 33 | auto ft_error = dbn->fine_tune(dataset.training_images, dataset.training_labels, 50); 34 | std::cout << "ft_error:" << ft_error << std::endl; 35 | CHECK(ft_error < 5e-2); 36 | 37 | TEST_CHECK(0.2); 38 | } 39 | -------------------------------------------------------------------------------- /test/src/misc/cdbn_sgd_2.cpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #include "dll_test.hpp" 9 | 10 | #include "dll/rbm/rbm.hpp" 11 | #include "dll/rbm/conv_rbm.hpp" 12 | #include "dll/dbn.hpp" 13 | 14 | #include "mnist/mnist_reader.hpp" 15 | #include "mnist/mnist_utils.hpp" 16 | 17 | DLL_TEST_CASE("cdbn/sgd/2", "[dbn][mnist][sgd]") { 18 | typedef dll::dbn_desc< 19 | dll::dbn_layers< 20 | dll::conv_rbm_square_desc<1, 28, 10, 17, dll::momentum, dll::batch_size<10>, dll::weight_type>::layer_t, 21 | dll::conv_rbm_square_desc<10, 12, 6, 7, dll::momentum, dll::batch_size<10>, dll::weight_type>::layer_t, 22 | dll::rbm_desc<6 * 6 * 6, 10, dll::momentum, dll::batch_size<10>, dll::hidden>::layer_t>, 23 | dll::trainer, dll::batch_size<10>>::dbn_t dbn_t; 24 | 25 | auto dataset = mnist::read_dataset_direct>(500); 26 | REQUIRE(!dataset.training_images.empty()); 27 | 28 | mnist::binarize_dataset(dataset); 29 | 30 | auto dbn = std::make_unique(); 31 | 32 | dbn->pretrain(dataset.training_images, 20); 33 | 34 | auto ft_error = dbn->fine_tune(dataset.training_images, dataset.training_labels, 50); 35 | std::cout << "ft_error:" << ft_error << std::endl; 36 | CHECK(ft_error < 5e-2); 37 | 38 | TEST_CHECK(0.2); 39 | } 40 | -------------------------------------------------------------------------------- /test/src/misc/cdbn_sgd_3.cpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #include "dll_test.hpp" 9 | 10 | #include "dll/rbm/rbm.hpp" 11 | #include "dll/rbm/conv_rbm.hpp" 12 | #include "dll/dbn.hpp" 13 | 14 | #include "mnist/mnist_reader.hpp" 15 | #include "mnist/mnist_utils.hpp" 16 | 17 | DLL_TEST_CASE("cdbn/sgd/3", "[dbn][mnist][sgd]") { 18 | typedef dll::dbn_desc< 19 | dll::dbn_layers< 20 | dll::conv_rbm_square_desc<1, 28, 10, 9, dll::momentum, dll::batch_size<10>, dll::weight_type>::layer_t, 21 | dll::conv_rbm_square_desc<10, 20, 10, 7, dll::momentum, dll::batch_size<10>, dll::weight_type>::layer_t, 22 | dll::rbm_desc<10 * 14 * 14, 700, dll::momentum, dll::batch_size<10>>::layer_t, 23 | dll::rbm_desc<700, 10, dll::momentum, dll::batch_size<10>, dll::hidden>::layer_t>, 24 | dll::trainer, dll::batch_size<10>>::dbn_t dbn_t; 25 | 26 | auto dataset = mnist::read_dataset_direct>(500); 27 | REQUIRE(!dataset.training_images.empty()); 28 | 29 | mnist::binarize_dataset(dataset); 30 | 31 | auto dbn = std::make_unique(); 32 | 33 | dbn->learning_rate = 0.05; 34 | 35 | dbn->pretrain(dataset.training_images, 20); 36 | 37 | auto ft_error = dbn->fine_tune(dataset.training_images, dataset.training_labels, 50); 38 | std::cout << "ft_error:" << ft_error << std::endl; 39 | CHECK(ft_error < 5e-2); 40 | 41 | TEST_CHECK(0.2); 42 | } 43 | -------------------------------------------------------------------------------- /test/src/misc/cdbn_sgd_4.cpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #include "dll_test.hpp" 9 | 10 | #include "dll/rbm/rbm.hpp" 11 | #include "dll/rbm/conv_rbm.hpp" 12 | #include "dll/dbn.hpp" 13 | #include "dll/transform/scale_layer.hpp" 14 | #include "dll/transform/shape_3d_layer.hpp" 15 | 16 | #include "mnist/mnist_reader.hpp" 17 | #include "mnist/mnist_utils.hpp" 18 | 19 | DLL_TEST_CASE("cdbn/sgd/4", "[dbn][mnist][sgd]") { 20 | typedef dll::dbn_desc< 21 | dll::dbn_layers< 22 | dll::shape_3d_layer_desc<1, 28, 28>::layer_t, 23 | dll::scale_layer_desc<1, 256>::layer_t, 24 | dll::conv_rbm_square_desc<1, 28, 10, 9, dll::momentum, dll::batch_size<10>, dll::weight_type>::layer_t, 25 | dll::conv_rbm_square_desc<10, 20, 10, 7, dll::momentum, dll::batch_size<10>, dll::weight_type>::layer_t, 26 | dll::rbm_desc<10 * 14 * 14, 700, dll::momentum, dll::batch_size<10>>::layer_t, 27 | dll::rbm_desc<700, 10, dll::momentum, dll::batch_size<10>, dll::hidden>::layer_t>, 28 | dll::trainer, dll::batch_size<10>>::dbn_t dbn_t; 29 | 30 | auto dataset = mnist::read_dataset_direct>(500); 31 | REQUIRE(!dataset.training_images.empty()); 32 | 33 | auto dbn = std::make_unique(); 34 | 35 | dbn->pretrain(dataset.training_images, 20); 36 | 37 | auto ft_error = dbn->fine_tune(dataset.training_images, dataset.training_labels, 50); 38 | std::cout << "ft_error:" << ft_error << std::endl; 39 | CHECK(ft_error < 5e-2); 40 | 41 | TEST_CHECK(0.2); 42 | } 43 | -------------------------------------------------------------------------------- /test/src/misc/dyn_conv_dbn.cpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #include "dll_test.hpp" 9 | 10 | #include "dll/rbm/dyn_conv_rbm.hpp" 11 | #include "dll/dbn.hpp" 12 | 13 | #include "mnist/mnist_reader.hpp" 14 | #include "mnist/mnist_utils.hpp" 15 | 16 | DLL_TEST_CASE("dyn_conv_dbn/mnist_1", "conv_dbn::simple") { 17 | typedef dll::dbn_desc< 18 | dll::dbn_layers< 19 | dll::dyn_conv_rbm_desc>::layer_t, 20 | dll::dyn_conv_rbm_desc>::layer_t, 21 | dll::dyn_conv_rbm_desc>::layer_t>>::dbn_t dbn_t; 22 | 23 | auto dataset = mnist::read_dataset_3d>(100); 24 | REQUIRE(!dataset.training_images.empty()); 25 | 26 | mnist::binarize_dataset(dataset); 27 | 28 | auto dbn = std::make_unique(); 29 | 30 | dbn->template layer_get<0>().init_layer(1, 28, 28, 40, 17, 17); 31 | dbn->template layer_get<1>().init_layer(40, 12, 12, 20, 3, 3); 32 | dbn->template layer_get<2>().init_layer(20, 10, 10, 50, 5, 5); 33 | 34 | dbn->pretrain(dataset.training_images, 5); 35 | } 36 | -------------------------------------------------------------------------------- /test/src/misc/dyn_crbm.cpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #include 9 | 10 | #include "dll_test.hpp" 11 | 12 | #include "dll/rbm/dyn_conv_rbm.hpp" 13 | 14 | #include "mnist/mnist_reader.hpp" 15 | #include "mnist/mnist_utils.hpp" 16 | 17 | DLL_TEST_CASE("dyn_crbm/mnist_1", "dyn_crbm::simple") { 18 | dll::dyn_conv_rbm_desc<>::layer_t rbm; 19 | 20 | rbm.init_layer(1, 28, 28, 40, 17, 17); 21 | 22 | auto dataset = mnist::read_dataset_direct>(250); 23 | 24 | REQUIRE(!dataset.training_images.empty()); 25 | 26 | mnist::binarize_dataset(dataset); 27 | 28 | auto error = rbm.train(dataset.training_images, 100); 29 | 30 | REQUIRE(error < 2e-2); 31 | } 32 | 33 | DLL_TEST_CASE("dyn_crbm/mnist_2", "crbm::momentum") { 34 | dll::dyn_conv_rbm_desc::layer_t rbm; 35 | 36 | rbm.init_layer(1, 28, 28, 40, 17, 17); 37 | 38 | auto dataset = mnist::read_dataset_direct>(250); 39 | 40 | REQUIRE(!dataset.training_images.empty()); 41 | 42 | mnist::binarize_dataset(dataset); 43 | 44 | auto error = rbm.train(dataset.training_images, 100); 45 | 46 | REQUIRE(error < 1e-2); 47 | } 48 | -------------------------------------------------------------------------------- /test/src/misc/dyn_crbm_mp.cpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #include 9 | 10 | #include "dll_test.hpp" 11 | 12 | #include "dll/rbm/dyn_conv_rbm_mp.hpp" 13 | 14 | #include "mnist/mnist_reader.hpp" 15 | #include "mnist/mnist_utils.hpp" 16 | 17 | DLL_TEST_CASE("dyn_crbm_mp/mnist_1", "crbm::simple") { 18 | dll::dyn_conv_rbm_mp_desc<>::layer_t rbm; 19 | 20 | rbm.init_layer(1, 28, 28, 40, 12, 12, 2); 21 | rbm.learning_rate = 0.01; 22 | 23 | auto dataset = mnist::read_dataset_direct>(500); 24 | REQUIRE(!dataset.training_images.empty()); 25 | 26 | mnist::binarize_dataset(dataset); 27 | 28 | auto error = rbm.train(dataset.training_images, 100); 29 | REQUIRE(error < 1e-1); 30 | } 31 | 32 | DLL_TEST_CASE("dyn_crbm_mp/mnist_2", "crbm::momentum") { 33 | dll::dyn_conv_rbm_mp_desc::layer_t rbm; 34 | 35 | rbm.init_layer(1, 28, 28, 40, 12, 12, 2); 36 | rbm.learning_rate = 0.01; 37 | 38 | auto dataset = mnist::read_dataset_direct>(100); 39 | REQUIRE(!dataset.training_images.empty()); 40 | 41 | mnist::binarize_dataset(dataset); 42 | 43 | auto error = rbm.train(dataset.training_images, 100); 44 | REQUIRE(error < 1e-2); 45 | } 46 | -------------------------------------------------------------------------------- /test/src/misc/dyn_dbn_sgd.cpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #include 9 | 10 | #include "dll_test.hpp" 11 | 12 | #include "dll/rbm/dyn_rbm.hpp" 13 | #include "dll/dbn.hpp" 14 | 15 | #include "mnist/mnist_reader.hpp" 16 | #include "mnist/mnist_utils.hpp" 17 | 18 | DLL_TEST_CASE("dyn_dbn/sgd/mnist/1", "dbn::simple") { 19 | using dbn_t = 20 | dll::dbn_desc< 21 | dll::dbn_layers< 22 | dll::dyn_rbm_desc::layer_t, 23 | dll::dyn_rbm_desc::layer_t, 24 | dll::dyn_rbm_desc>::layer_t>, 25 | dll::trainer>::dbn_t; 26 | 27 | auto dataset = mnist::read_dataset_direct>(500); 28 | REQUIRE(!dataset.training_images.empty()); 29 | 30 | mnist::binarize_dataset(dataset); 31 | 32 | auto dbn = std::make_unique(); 33 | 34 | dbn->template layer_get<0>().init_layer(28 * 28, 100); 35 | dbn->template layer_get<1>().init_layer(100, 200); 36 | dbn->template layer_get<2>().init_layer(200, 10); 37 | 38 | dbn->pretrain(dataset.training_images, 20); 39 | 40 | auto ft_error = dbn->fine_tune(dataset.training_images, dataset.training_labels, 100); 41 | std::cout << "ft_error:" << ft_error << std::endl; 42 | CHECK(ft_error < 5e-2); 43 | 44 | TEST_CHECK(0.2); 45 | } 46 | -------------------------------------------------------------------------------- /test/src/misc/rbm_pcd.cpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #include "dll_test.hpp" 9 | 10 | #include "dll/rbm/rbm.hpp" 11 | 12 | #include "mnist/mnist_reader.hpp" 13 | #include "mnist/mnist_utils.hpp" 14 | 15 | DLL_TEST_CASE("rbm/mnist_3", "rbm::pcd_trainer") { 16 | dll::rbm_desc< 17 | 28 * 28, 100, 18 | dll::batch_size<25>, 19 | dll::momentum, 20 | dll::trainer_rbm>::layer_t rbm; 21 | 22 | auto dataset = mnist::read_dataset_direct>(100); 23 | REQUIRE(!dataset.training_images.empty()); 24 | 25 | mnist::binarize_dataset(dataset); 26 | 27 | auto error = rbm.train(dataset.training_images, 200); 28 | 29 | REQUIRE(error < 1e-1); 30 | } 31 | 32 | //TODO Still not very convincing 33 | DLL_TEST_CASE("rbm/mnist_15", "rbm::pcd_gaussian") { 34 | dll::rbm_desc< 35 | 28 * 28, 144, 36 | dll::batch_size<25>, 37 | dll::momentum, 38 | dll::trainer_rbm, 39 | dll::visible>::layer_t rbm; 40 | 41 | rbm.learning_rate /= 20.0; 42 | 43 | auto dataset = mnist::read_dataset_direct>(500); 44 | REQUIRE(!dataset.training_images.empty()); 45 | 46 | mnist::normalize_dataset(dataset); 47 | 48 | auto error = rbm.train(dataset.training_images, 100); 49 | 50 | REQUIRE(error < 5e-2); 51 | } 52 | -------------------------------------------------------------------------------- /test/src/misc/test.cpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN 9 | #include "dll_test.hpp" 10 | -------------------------------------------------------------------------------- /test/src/perf/conv_dbn_mp.cpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #include 9 | 10 | #include "dll_test.hpp" 11 | 12 | #include "dll/rbm/conv_rbm_mp.hpp" 13 | #include "dll/dbn.hpp" 14 | 15 | #include "mnist/mnist_reader.hpp" 16 | #include "mnist/mnist_utils.hpp" 17 | 18 | DLL_TEST_CASE("conv_dbn_mp/mnist_slow", "[cdbn][slow][benchmark]") { 19 | typedef dll::dbn_desc< 20 | dll::dbn_layers< 21 | dll::conv_rbm_mp_desc_square<1, 28, 40, 13, 2, dll::momentum, dll::batch_size<25>>::layer_t, 22 | dll::conv_rbm_mp_desc_square<40, 8, 40, 5, 2, dll::momentum, dll::batch_size<25>>::layer_t>>::dbn_t dbn_t; 23 | 24 | auto dataset = mnist::read_dataset_direct>(250); 25 | 26 | mnist::binarize_dataset(dataset); 27 | 28 | auto dbn = std::make_unique(); 29 | 30 | dbn->pretrain(dataset.training_images, 20); 31 | } 32 | -------------------------------------------------------------------------------- /test/src/perf/conv_dbn_slow.cpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #include "dll_test.hpp" 9 | 10 | #include "dll/rbm/conv_rbm.hpp" 11 | #include "dll/dbn.hpp" 12 | 13 | #include "mnist/mnist_reader.hpp" 14 | #include "mnist/mnist_utils.hpp" 15 | 16 | DLL_TEST_CASE("conv_dbn/mnist_slow", "[cdbn][slow][benchmark]") { 17 | typedef dll::dbn_desc< 18 | dll::dbn_layers< 19 | dll::conv_rbm_square_desc<1, 28, 40, 17, dll::momentum, dll::batch_size<25>>::layer_t, 20 | dll::conv_rbm_square_desc<40, 12, 40, 3, dll::momentum, dll::batch_size<25>>::layer_t, 21 | dll::conv_rbm_square_desc<40, 10, 40, 5, dll::momentum, dll::batch_size<25>>::layer_t>, dll::trainer>::dbn_t dbn_t; 22 | 23 | auto dataset = mnist::read_dataset_direct>(1000); 24 | REQUIRE(!dataset.training_images.empty()); 25 | 26 | mnist::binarize_dataset(dataset); 27 | 28 | auto dbn = std::make_unique(); 29 | 30 | dbn->pretrain(dataset.training_images, 5); 31 | } 32 | -------------------------------------------------------------------------------- /test/src/perf/dbn_sgd_perf.cpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #include 9 | 10 | #include "dll_test.hpp" 11 | 12 | #include "dll/neural/dense/dense_layer.hpp" 13 | #include "dll/dbn.hpp" 14 | 15 | #include "mnist/mnist_reader.hpp" 16 | #include "mnist/mnist_utils.hpp" 17 | 18 | // This test case is done to benchmark the performance of SGD 19 | DLL_TEST_CASE("dbn/sgd/perf/1", "[dbn][mnist][sgd][perf]") { 20 | using dbn_t = dll::dbn_desc< 21 | dll::dbn_layers< 22 | dll::dense_layer_desc<28 * 28, 500>::layer_t, 23 | dll::dense_layer_desc<500, 250>::layer_t, 24 | dll::dense_layer_desc<250, 10, dll::activation>::layer_t>, 25 | dll::updater, dll::batch_size<100>, dll::trainer>::dbn_t; 26 | 27 | auto dataset = mnist::read_dataset_direct>(2000); 28 | REQUIRE(!dataset.training_images.empty()); 29 | 30 | mnist::binarize_dataset(dataset); 31 | 32 | auto dbn = std::make_unique(); 33 | 34 | auto ft_error = dbn->fine_tune(dataset.training_images, dataset.training_labels, 50); 35 | std::cout << "ft_error:" << ft_error << std::endl; 36 | CHECK(ft_error < 5e-2); 37 | 38 | TEST_CHECK(0.2); 39 | } 40 | -------------------------------------------------------------------------------- /test/src/perf/dyn_rbm.cpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #include "dll_test.hpp" 9 | 10 | #include "dll/rbm/dyn_rbm.hpp" 11 | 12 | #include "mnist/mnist_reader.hpp" 13 | #include "mnist/mnist_utils.hpp" 14 | 15 | //Only here for benchmarking purposes 16 | DLL_TEST_CASE("dyn_rbm/mnist_14", "rbm::slow") { 17 | dll::dyn_rbm_desc<>::layer_t rbm(28 * 28, 400); 18 | 19 | auto dataset = mnist::read_dataset_direct>(100); 20 | REQUIRE(!dataset.training_images.empty()); 21 | 22 | mnist::binarize_dataset(dataset); 23 | 24 | auto error = rbm.train(dataset.training_images, 10); 25 | 26 | REQUIRE(error < 5e-2); 27 | } 28 | -------------------------------------------------------------------------------- /test/src/perf/rbm_perf.cpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #include "dll_test.hpp" 9 | 10 | #include "dll/rbm/rbm.hpp" 11 | 12 | #include "mnist/mnist_reader.hpp" 13 | #include "mnist/mnist_utils.hpp" 14 | 15 | //Only here for debugging purposes 16 | DLL_TEST_CASE("rbm/perf/1", "rbm::fast") { 17 | dll::rbm_desc< 18 | 28 * 28, 100, 19 | dll::batch_size<5>>::layer_t rbm; 20 | 21 | auto dataset = mnist::read_dataset_direct>(25); 22 | REQUIRE(!dataset.training_images.empty()); 23 | 24 | mnist::binarize_dataset(dataset); 25 | 26 | auto error = rbm.train(dataset.training_images, 5); 27 | 28 | REQUIRE(error < 5e-1); 29 | 30 | dll::dump_timers(); 31 | } 32 | 33 | DLL_TEST_CASE("rbm/perf/2", "rbm::slow") { 34 | dll::rbm_desc< 35 | 28 * 28, 459, 36 | dll::batch_size<48>>::layer_t rbm; 37 | 38 | auto dataset = mnist::read_dataset_direct>(1099); 39 | REQUIRE(!dataset.training_images.empty()); 40 | 41 | mnist::binarize_dataset(dataset); 42 | 43 | auto error = rbm.train(dataset.training_images, 15); 44 | 45 | REQUIRE(error < 5e-2); 46 | 47 | dll::dump_timers(); 48 | } 49 | -------------------------------------------------------------------------------- /test/src/perf/test.cpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN 9 | #include "dll_test.hpp" 10 | -------------------------------------------------------------------------------- /test/src/unit/dbn_ae.cpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #include 9 | 10 | #include "dll_test.hpp" 11 | 12 | #include "dll/rbm/rbm.hpp" 13 | #include "dll/rbm/dyn_rbm.hpp" 14 | #include "dll/dbn.hpp" 15 | #include "dll/transform/shape_1d_layer.hpp" 16 | #include "dll/transform/binarize_layer.hpp" 17 | 18 | #include "mnist/mnist_reader.hpp" 19 | #include "mnist/mnist_utils.hpp" 20 | 21 | DLL_TEST_CASE("dbn/ae/1", "[unit][rbm][dbn][mnist][sgd][ae]") { 22 | typedef dll::dbn_desc< 23 | dll::dbn_layers< 24 | dll::rbm_desc<28 * 28, 32, dll::momentum, dll::batch_size<25>>::layer_t, 25 | dll::rbm_desc<32, 28 * 28, dll::momentum, dll::batch_size<25>>::layer_t 26 | >, dll::autoencoder, dll::loss, dll::trainer, dll::batch_size<10>>::dbn_t dbn_t; 27 | 28 | auto dataset = mnist::read_dataset_direct>(500); 29 | REQUIRE(!dataset.training_images.empty()); 30 | 31 | dll_test::mnist_scale(dataset); 32 | 33 | auto dbn = std::make_unique(); 34 | 35 | dbn->display(); 36 | 37 | dbn->pretrain(dataset.training_images, 20); 38 | 39 | dbn->learning_rate = 0.1; 40 | 41 | auto ft_error = dbn->fine_tune_ae(dataset.training_images, 25); 42 | std::cout << "ft_error:" << ft_error << std::endl; 43 | 44 | CHECK(ft_error < 0.1); 45 | 46 | auto test_error = dll::test_set_ae(*dbn, dataset.test_images); 47 | std::cout << "test_error:" << test_error << std::endl; 48 | REQUIRE(test_error < 0.1); 49 | } 50 | -------------------------------------------------------------------------------- /test/src/unit/dyn_rbm.cpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #include "dll_test.hpp" 9 | 10 | #include "dll/rbm/dyn_rbm.hpp" 11 | 12 | #include "mnist/mnist_reader.hpp" 13 | #include "mnist/mnist_utils.hpp" 14 | 15 | DLL_TEST_CASE("unit/dyn_rbm/mnist/1", "[rbm][dyn][momentum][unit]") { 16 | dll::dyn_rbm_desc< 17 | dll::momentum>::layer_t rbm(28 * 28, 100); 18 | 19 | auto dataset = mnist::read_dataset_direct>(100); 20 | REQUIRE(!dataset.training_images.empty()); 21 | 22 | mnist::binarize_dataset(dataset); 23 | 24 | auto error = rbm.train(dataset.training_images, 50); 25 | REQUIRE(error < 5e-2); 26 | } 27 | 28 | DLL_TEST_CASE("unit/dyn_rbm/mnist/2", "[rbm][dyn][gaussian][momentum][unit]") { 29 | dll::dyn_rbm_desc< 30 | dll::visible, 31 | dll::momentum>::layer_t rbm(28 * 28, 100); 32 | 33 | rbm.learning_rate *= 10; 34 | 35 | auto dataset = mnist::read_dataset_direct>(75); 36 | REQUIRE(!dataset.training_images.empty()); 37 | 38 | mnist::normalize_dataset(dataset); 39 | 40 | auto error = rbm.train(dataset.training_images, 50); 41 | REQUIRE(error < 1e-1); 42 | } 43 | 44 | DLL_TEST_CASE("unit/dyn_rbm/mnist/3", "[rbm][dyn][relu][momentum][unit]") { 45 | dll::dyn_rbm_desc< 46 | dll::hidden, 47 | dll::momentum>::layer_t rbm(28 * 28, 100); 48 | 49 | auto dataset = mnist::read_dataset_direct>(100); 50 | REQUIRE(!dataset.training_images.empty()); 51 | 52 | mnist::binarize_dataset(dataset); 53 | 54 | auto error = rbm.train(dataset.training_images, 50); 55 | REQUIRE(error < 5e-2); 56 | } 57 | -------------------------------------------------------------------------------- /test/src/unit/rbm_types.cpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | /* 9 | * This is mostly a compilation test to ensure that RBM is accepting 10 | * enough input types 11 | */ 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | #include "dll_test.hpp" 18 | #include "template_test.hpp" 19 | 20 | #include "dll/rbm/rbm.hpp" 21 | #include "dll/rbm/dyn_rbm.hpp" 22 | 23 | #include "mnist/mnist_reader.hpp" 24 | #include "mnist/mnist_utils.hpp" 25 | 26 | namespace { 27 | 28 | struct rbm_double { 29 | using rbm_t = dll::rbm_desc< 30 | 28 * 28, 100, 31 | dll::weight_type, 32 | dll::batch_size<25>>::layer_t; 33 | 34 | static void init(rbm_t&){} 35 | }; 36 | 37 | struct rbm_float { 38 | using rbm_t = dll::rbm_desc< 39 | 28 * 28, 100, 40 | dll::weight_type, 41 | dll::batch_size<25>>::layer_t; 42 | 43 | static void init(rbm_t&){} 44 | }; 45 | 46 | struct dyn_rbm_float { 47 | using rbm_t = dll::dyn_rbm_desc< 48 | dll::weight_type 49 | , dll::batch_size<25> 50 | >::layer_t; 51 | 52 | static void init(rbm_t& rbm){ 53 | rbm.init_layer(28 * 28, 100); 54 | } 55 | }; 56 | 57 | struct dyn_rbm_double { 58 | using rbm_t = dll::dyn_rbm_desc< 59 | dll::weight_type 60 | , dll::batch_size<25> 61 | >::layer_t; 62 | 63 | static void init(rbm_t& rbm){ 64 | rbm.init_layer(28 * 28, 100); 65 | } 66 | }; 67 | 68 | } // end of anonymous namespace 69 | 70 | #define TYPES_TEST_PREFIX "rbm" 71 | #define FLOAT_TYPES_TEST_T1 rbm_float 72 | #define FLOAT_TYPES_TEST_T2 dyn_rbm_float 73 | #define DOUBLE_TYPES_TEST_T1 rbm_double 74 | #define DOUBLE_TYPES_TEST_T2 dyn_rbm_double 75 | 76 | #include "types_test.inl" 77 | -------------------------------------------------------------------------------- /test/src/unit/test.cpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN 9 | #include "dll_test.hpp" 10 | -------------------------------------------------------------------------------- /test/text_db/images/1.dat: -------------------------------------------------------------------------------- 1 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 2 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 3 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 4 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 5 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 6 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 7 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 8 | 0;0;0;0;0;0;84;185;159;151;60;36;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 9 | 0;0;0;0;0;0;222;254;254;254;254;241;198;198;198;198;198;198;198;198;170;52;0;0;0;0;0;0; 10 | 0;0;0;0;0;0;67;114;72;114;163;227;254;225;254;254;254;250;229;254;254;140;0;0;0;0;0;0; 11 | 0;0;0;0;0;0;0;0;0;0;0;17;66;14;67;67;67;59;21;236;254;106;0;0;0;0;0;0; 12 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;83;253;209;18;0;0;0;0;0;0; 13 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;22;233;255;83;0;0;0;0;0;0;0; 14 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;129;254;238;44;0;0;0;0;0;0;0; 15 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;59;249;254;62;0;0;0;0;0;0;0;0; 16 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;133;254;187;5;0;0;0;0;0;0;0;0; 17 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;9;205;248;58;0;0;0;0;0;0;0;0;0; 18 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;126;254;182;0;0;0;0;0;0;0;0;0;0; 19 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;75;251;240;57;0;0;0;0;0;0;0;0;0;0; 20 | 0;0;0;0;0;0;0;0;0;0;0;0;0;19;221;254;166;0;0;0;0;0;0;0;0;0;0;0; 21 | 0;0;0;0;0;0;0;0;0;0;0;0;3;203;254;219;35;0;0;0;0;0;0;0;0;0;0;0; 22 | 0;0;0;0;0;0;0;0;0;0;0;0;38;254;254;77;0;0;0;0;0;0;0;0;0;0;0;0; 23 | 0;0;0;0;0;0;0;0;0;0;0;31;224;254;115;1;0;0;0;0;0;0;0;0;0;0;0;0; 24 | 0;0;0;0;0;0;0;0;0;0;0;133;254;254;52;0;0;0;0;0;0;0;0;0;0;0;0;0; 25 | 0;0;0;0;0;0;0;0;0;0;61;242;254;254;52;0;0;0;0;0;0;0;0;0;0;0;0;0; 26 | 0;0;0;0;0;0;0;0;0;0;121;254;254;219;40;0;0;0;0;0;0;0;0;0;0;0;0;0; 27 | 0;0;0;0;0;0;0;0;0;0;121;254;207;18;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 28 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 29 | -------------------------------------------------------------------------------- /test/text_db/images/2.dat: -------------------------------------------------------------------------------- 1 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 2 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 3 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 4 | 0;0;0;0;0;0;0;0;0;0;116;125;171;255;255;150;93;0;0;0;0;0;0;0;0;0;0;0; 5 | 0;0;0;0;0;0;0;0;0;169;253;253;253;253;253;253;218;30;0;0;0;0;0;0;0;0;0;0; 6 | 0;0;0;0;0;0;0;0;169;253;253;253;213;142;176;253;253;122;0;0;0;0;0;0;0;0;0;0; 7 | 0;0;0;0;0;0;0;52;250;253;210;32;12;0;6;206;253;140;0;0;0;0;0;0;0;0;0;0; 8 | 0;0;0;0;0;0;0;77;251;210;25;0;0;0;122;248;253;65;0;0;0;0;0;0;0;0;0;0; 9 | 0;0;0;0;0;0;0;0;31;18;0;0;0;0;209;253;253;65;0;0;0;0;0;0;0;0;0;0; 10 | 0;0;0;0;0;0;0;0;0;0;0;0;0;117;247;253;198;10;0;0;0;0;0;0;0;0;0;0; 11 | 0;0;0;0;0;0;0;0;0;0;0;0;76;247;253;231;63;0;0;0;0;0;0;0;0;0;0;0; 12 | 0;0;0;0;0;0;0;0;0;0;0;0;128;253;253;144;0;0;0;0;0;0;0;0;0;0;0;0; 13 | 0;0;0;0;0;0;0;0;0;0;0;176;246;253;159;12;0;0;0;0;0;0;0;0;0;0;0;0; 14 | 0;0;0;0;0;0;0;0;0;0;25;234;253;233;35;0;0;0;0;0;0;0;0;0;0;0;0;0; 15 | 0;0;0;0;0;0;0;0;0;0;198;253;253;141;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 16 | 0;0;0;0;0;0;0;0;0;78;248;253;189;12;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 17 | 0;0;0;0;0;0;0;0;19;200;253;253;141;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 18 | 0;0;0;0;0;0;0;0;134;253;253;173;12;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 19 | 0;0;0;0;0;0;0;0;248;253;253;25;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 20 | 0;0;0;0;0;0;0;0;248;253;253;43;20;20;20;20;5;0;5;20;20;37;150;150;150;147;10;0; 21 | 0;0;0;0;0;0;0;0;248;253;253;253;253;253;253;253;168;143;166;253;253;253;253;253;253;253;123;0; 22 | 0;0;0;0;0;0;0;0;174;253;253;253;253;253;253;253;253;253;253;253;249;247;247;169;117;117;57;0; 23 | 0;0;0;0;0;0;0;0;0;118;123;123;123;166;253;253;253;155;123;123;41;0;0;0;0;0;0;0; 24 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 25 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 26 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 27 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 28 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 29 | -------------------------------------------------------------------------------- /test/text_db/images/3.dat: -------------------------------------------------------------------------------- 1 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 2 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 3 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 4 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 5 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;38;254;109;0;0;0;0;0;0;0;0;0; 6 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;87;252;82;0;0;0;0;0;0;0;0;0; 7 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;135;241;0;0;0;0;0;0;0;0;0;0; 8 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;45;244;150;0;0;0;0;0;0;0;0;0;0; 9 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;84;254;63;0;0;0;0;0;0;0;0;0;0; 10 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;202;223;11;0;0;0;0;0;0;0;0;0;0; 11 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;32;254;216;0;0;0;0;0;0;0;0;0;0;0; 12 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;95;254;195;0;0;0;0;0;0;0;0;0;0;0; 13 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;140;254;77;0;0;0;0;0;0;0;0;0;0;0; 14 | 0;0;0;0;0;0;0;0;0;0;0;0;0;57;237;205;8;0;0;0;0;0;0;0;0;0;0;0; 15 | 0;0;0;0;0;0;0;0;0;0;0;0;0;124;255;165;0;0;0;0;0;0;0;0;0;0;0;0; 16 | 0;0;0;0;0;0;0;0;0;0;0;0;0;171;254;81;0;0;0;0;0;0;0;0;0;0;0;0; 17 | 0;0;0;0;0;0;0;0;0;0;0;0;24;232;215;0;0;0;0;0;0;0;0;0;0;0;0;0; 18 | 0;0;0;0;0;0;0;0;0;0;0;0;120;254;159;0;0;0;0;0;0;0;0;0;0;0;0;0; 19 | 0;0;0;0;0;0;0;0;0;0;0;0;151;254;142;0;0;0;0;0;0;0;0;0;0;0;0;0; 20 | 0;0;0;0;0;0;0;0;0;0;0;0;228;254;66;0;0;0;0;0;0;0;0;0;0;0;0;0; 21 | 0;0;0;0;0;0;0;0;0;0;0;61;251;254;66;0;0;0;0;0;0;0;0;0;0;0;0;0; 22 | 0;0;0;0;0;0;0;0;0;0;0;141;254;205;3;0;0;0;0;0;0;0;0;0;0;0;0;0; 23 | 0;0;0;0;0;0;0;0;0;0;10;215;254;121;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 24 | 0;0;0;0;0;0;0;0;0;0;5;198;176;10;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 25 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 26 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 27 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 28 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 29 | -------------------------------------------------------------------------------- /test/text_db/images/4.dat: -------------------------------------------------------------------------------- 1 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 2 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 3 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 4 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 5 | 0;0;0;0;0;0;0;0;0;0;0;0;11;150;253;202;31;0;0;0;0;0;0;0;0;0;0;0; 6 | 0;0;0;0;0;0;0;0;0;0;0;0;37;251;251;253;107;0;0;0;0;0;0;0;0;0;0;0; 7 | 0;0;0;0;0;0;0;0;0;0;0;21;197;251;251;253;107;0;0;0;0;0;0;0;0;0;0;0; 8 | 0;0;0;0;0;0;0;0;0;0;110;190;251;251;251;253;169;109;62;0;0;0;0;0;0;0;0;0; 9 | 0;0;0;0;0;0;0;0;0;0;253;251;251;251;251;253;251;251;220;51;0;0;0;0;0;0;0;0; 10 | 0;0;0;0;0;0;0;0;0;182;255;253;253;253;253;234;222;253;253;253;0;0;0;0;0;0;0;0; 11 | 0;0;0;0;0;0;0;0;63;221;253;251;251;251;147;77;62;128;251;251;105;0;0;0;0;0;0;0; 12 | 0;0;0;0;0;0;0;32;231;251;253;251;220;137;10;0;0;31;230;251;243;113;5;0;0;0;0;0; 13 | 0;0;0;0;0;0;0;37;251;251;253;188;20;0;0;0;0;0;109;251;253;251;35;0;0;0;0;0; 14 | 0;0;0;0;0;0;0;37;251;251;201;30;0;0;0;0;0;0;31;200;253;251;35;0;0;0;0;0; 15 | 0;0;0;0;0;0;0;37;253;253;0;0;0;0;0;0;0;0;32;202;255;253;164;0;0;0;0;0; 16 | 0;0;0;0;0;0;0;140;251;251;0;0;0;0;0;0;0;0;109;251;253;251;35;0;0;0;0;0; 17 | 0;0;0;0;0;0;0;217;251;251;0;0;0;0;0;0;21;63;231;251;253;230;30;0;0;0;0;0; 18 | 0;0;0;0;0;0;0;217;251;251;0;0;0;0;0;0;144;251;251;251;221;61;0;0;0;0;0;0; 19 | 0;0;0;0;0;0;0;217;251;251;0;0;0;0;0;182;221;251;251;251;180;0;0;0;0;0;0;0; 20 | 0;0;0;0;0;0;0;218;253;253;73;73;228;253;253;255;253;253;253;253;0;0;0;0;0;0;0;0; 21 | 0;0;0;0;0;0;0;113;251;251;253;251;251;251;251;253;251;251;251;147;0;0;0;0;0;0;0;0; 22 | 0;0;0;0;0;0;0;31;230;251;253;251;251;251;251;253;230;189;35;10;0;0;0;0;0;0;0;0; 23 | 0;0;0;0;0;0;0;0;62;142;253;251;251;251;251;253;107;0;0;0;0;0;0;0;0;0;0;0; 24 | 0;0;0;0;0;0;0;0;0;0;72;174;251;173;71;72;30;0;0;0;0;0;0;0;0;0;0;0; 25 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 26 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 27 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 28 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 29 | -------------------------------------------------------------------------------- /test/text_db/images/5.dat: -------------------------------------------------------------------------------- 1 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 2 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 3 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 4 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 5 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 6 | 0;0;0;0;0;0;0;0;0;0;50;224;0;0;0;0;0;0;0;70;29;0;0;0;0;0;0;0; 7 | 0;0;0;0;0;0;0;0;0;0;121;231;0;0;0;0;0;0;0;148;168;0;0;0;0;0;0;0; 8 | 0;0;0;0;0;0;0;0;0;4;195;231;0;0;0;0;0;0;0;96;210;11;0;0;0;0;0;0; 9 | 0;0;0;0;0;0;0;0;0;69;252;134;0;0;0;0;0;0;0;114;252;21;0;0;0;0;0;0; 10 | 0;0;0;0;0;0;0;0;45;236;217;12;0;0;0;0;0;0;0;192;252;21;0;0;0;0;0;0; 11 | 0;0;0;0;0;0;0;0;168;247;53;0;0;0;0;0;0;0;18;255;253;21;0;0;0;0;0;0; 12 | 0;0;0;0;0;0;0;84;242;211;0;0;0;0;0;0;0;0;141;253;189;5;0;0;0;0;0;0; 13 | 0;0;0;0;0;0;0;169;252;106;0;0;0;0;0;0;0;32;232;250;66;0;0;0;0;0;0;0; 14 | 0;0;0;0;0;0;15;225;252;0;0;0;0;0;0;0;0;134;252;211;0;0;0;0;0;0;0;0; 15 | 0;0;0;0;0;0;22;252;164;0;0;0;0;0;0;0;0;169;252;167;0;0;0;0;0;0;0;0; 16 | 0;0;0;0;0;0;9;204;209;18;0;0;0;0;0;0;22;253;253;107;0;0;0;0;0;0;0;0; 17 | 0;0;0;0;0;0;0;169;252;199;85;85;85;85;129;164;195;252;252;106;0;0;0;0;0;0;0;0; 18 | 0;0;0;0;0;0;0;41;170;245;252;252;252;252;232;231;251;252;252;9;0;0;0;0;0;0;0;0; 19 | 0;0;0;0;0;0;0;0;0;49;84;84;84;84;0;0;161;252;252;0;0;0;0;0;0;0;0;0; 20 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;127;252;252;45;0;0;0;0;0;0;0;0; 21 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;128;253;253;0;0;0;0;0;0;0;0;0; 22 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;127;252;252;0;0;0;0;0;0;0;0;0; 23 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;135;252;244;0;0;0;0;0;0;0;0;0; 24 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;232;236;111;0;0;0;0;0;0;0;0;0; 25 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;179;66;0;0;0;0;0;0;0;0;0;0; 26 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 27 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 28 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 29 | -------------------------------------------------------------------------------- /test/text_db/images/6.dat: -------------------------------------------------------------------------------- 1 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 2 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 3 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 4 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 5 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 6 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;77;254;107;3;0;0;0;0;0;0;0;0; 7 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;19;227;254;254;9;0;0;0;0;0;0;0;0; 8 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;81;254;254;165;1;0;0;0;0;0;0;0;0; 9 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;7;203;254;254;73;0;0;0;0;0;0;0;0;0; 10 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;53;254;254;250;0;0;0;0;0;0;0;0;0;0; 11 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;134;254;254;180;0;0;0;0;0;0;0;0;0;0; 12 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;196;254;248;48;0;0;0;0;0;0;0;0;0;0; 13 | 0;0;0;0;0;0;0;0;0;0;0;0;0;58;254;254;237;0;0;0;0;0;0;0;0;0;0;0; 14 | 0;0;0;0;0;0;0;0;0;0;0;0;0;111;254;254;132;0;0;0;0;0;0;0;0;0;0;0; 15 | 0;0;0;0;0;0;0;0;0;0;0;0;0;163;254;238;28;0;0;0;0;0;0;0;0;0;0;0; 16 | 0;0;0;0;0;0;0;0;0;0;0;0;60;252;254;223;0;0;0;0;0;0;0;0;0;0;0;0; 17 | 0;0;0;0;0;0;0;0;0;0;0;0;79;254;254;154;0;0;0;0;0;0;0;0;0;0;0;0; 18 | 0;0;0;0;0;0;0;0;0;0;0;0;163;254;238;53;0;0;0;0;0;0;0;0;0;0;0;0; 19 | 0;0;0;0;0;0;0;0;0;0;0;28;252;254;210;0;0;0;0;0;0;0;0;0;0;0;0;0; 20 | 0;0;0;0;0;0;0;0;0;0;0;86;254;254;131;0;0;0;0;0;0;0;0;0;0;0;0;0; 21 | 0;0;0;0;0;0;0;0;0;0;0;105;254;234;20;0;0;0;0;0;0;0;0;0;0;0;0;0; 22 | 0;0;0;0;0;0;0;0;0;0;0;175;254;204;5;0;0;0;0;0;0;0;0;0;0;0;0;0; 23 | 0;0;0;0;0;0;0;0;0;0;5;211;254;196;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 24 | 0;0;0;0;0;0;0;0;0;0;3;158;254;160;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 25 | 0;0;0;0;0;0;0;0;0;0;0;26;157;107;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 26 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 27 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 28 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 29 | -------------------------------------------------------------------------------- /test/text_db/images/7.dat: -------------------------------------------------------------------------------- 1 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 2 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 3 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 4 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 5 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 6 | 0;0;0;0;0;0;0;0;0;22;192;134;32;0;0;0;0;0;0;0;0;15;77;5;0;0;0;0; 7 | 0;0;0;0;0;0;0;0;17;235;250;169;0;0;0;0;0;0;0;0;15;220;241;37;0;0;0;0; 8 | 0;0;0;0;0;0;0;20;189;253;147;0;0;0;0;0;0;0;0;0;139;253;100;0;0;0;0;0; 9 | 0;0;0;0;0;0;0;70;253;253;21;0;0;0;0;0;0;0;0;43;254;173;13;0;0;0;0;0; 10 | 0;0;0;0;0;0;22;153;253;96;0;0;0;0;0;0;0;0;43;231;254;92;0;0;0;0;0;0; 11 | 0;0;0;0;0;0;163;255;204;11;0;0;0;0;0;0;0;0;104;254;158;0;0;0;0;0;0;0; 12 | 0;0;0;0;0;0;162;253;178;5;0;0;0;0;0;0;9;131;237;253;0;0;0;0;0;0;0;0; 13 | 0;0;0;0;0;0;162;253;253;191;175;70;70;70;70;133;197;253;253;169;0;0;0;0;0;0;0;0; 14 | 0;0;0;0;0;0;51;228;253;253;254;253;253;253;253;254;253;253;219;35;0;0;0;0;0;0;0;0; 15 | 0;0;0;0;0;0;0;17;65;137;254;232;137;137;137;44;253;253;161;0;0;0;0;0;0;0;0;0; 16 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;34;254;206;21;0;0;0;0;0;0;0;0;0; 17 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;160;253;69;0;0;0;0;0;0;0;0;0;0; 18 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;85;254;241;50;0;0;0;0;0;0;0;0;0;0; 19 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;158;254;165;0;0;0;0;0;0;0;0;0;0;0; 20 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;231;244;50;0;0;0;0;0;0;0;0;0;0;0; 21 | 0;0;0;0;0;0;0;0;0;0;0;0;0;104;254;232;0;0;0;0;0;0;0;0;0;0;0;0; 22 | 0;0;0;0;0;0;0;0;0;0;0;0;0;208;253;157;0;13;30;0;0;0;0;0;0;0;0;0; 23 | 0;0;0;0;0;0;0;0;0;0;0;0;0;208;253;154;91;204;161;0;0;0;0;0;0;0;0;0; 24 | 0;0;0;0;0;0;0;0;0;0;0;0;0;208;253;254;253;154;29;0;0;0;0;0;0;0;0;0; 25 | 0;0;0;0;0;0;0;0;0;0;0;0;0;61;190;128;23;6;0;0;0;0;0;0;0;0;0;0; 26 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 27 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 28 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 29 | -------------------------------------------------------------------------------- /test/text_db/images/8.dat: -------------------------------------------------------------------------------- 1 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 2 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 3 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 4 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 5 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 6 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 7 | 0;0;0;0;0;0;0;0;0;0;0;14;149;193;5;0;0;0;0;0;0;0;0;0;0;0;0;0; 8 | 0;0;0;0;0;0;0;0;0;0;91;224;253;253;19;0;0;0;0;0;0;0;0;0;0;0;0;0; 9 | 0;0;0;0;0;0;0;0;0;28;235;254;253;253;166;18;0;0;0;0;0;0;0;0;0;0;0;0; 10 | 0;0;0;0;0;0;0;0;0;144;253;254;253;253;253;238;115;6;0;0;0;0;0;0;0;0;0;0; 11 | 0;0;0;0;0;0;0;0;31;241;253;208;185;253;253;253;231;24;0;0;0;0;0;0;0;0;0;0; 12 | 0;0;0;0;0;0;0;0;79;254;193;0;8;98;219;254;255;201;18;0;0;0;0;0;0;0;0;0; 13 | 0;0;0;0;0;0;0;0;86;253;80;0;0;0;182;253;254;191;12;0;0;0;0;0;0;0;0;0; 14 | 0;0;0;0;0;0;0;0;175;253;155;0;0;0;234;253;254;135;0;0;0;0;0;0;0;0;0;0; 15 | 0;0;0;0;0;0;0;0;86;253;208;40;85;166;251;237;254;236;42;0;0;0;0;0;0;0;0;0; 16 | 0;0;0;0;0;0;0;0;18;238;253;254;253;253;185;36;216;253;152;0;0;0;0;0;0;0;0;0; 17 | 0;0;0;0;0;0;0;0;0;68;240;255;254;145;8;0;134;254;223;35;0;0;0;0;0;0;0;0; 18 | 0;0;0;0;0;0;0;0;0;0;68;158;142;12;0;0;9;175;253;161;0;0;0;0;0;0;0;0; 19 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;88;253;226;18;0;0;0;0;0;0;0; 20 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;2;166;253;126;0;0;0;0;0;0;0; 21 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;48;245;253;38;0;0;0;0;0;0; 22 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;115;254;172;9;0;0;0;0;0; 23 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;21;218;254;46;0;0;0;0;0; 24 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;30;254;165;0;0;0;0;0; 25 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;186;244;42;0;0;0;0; 26 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;14;223;78;0;0;0;0; 27 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 28 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 29 | -------------------------------------------------------------------------------- /test/text_db/images/9.dat: -------------------------------------------------------------------------------- 1 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 2 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 3 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 4 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 5 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;17;47;47;47;16;129;85;47;0;0;0; 6 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;75;153;217;253;253;253;215;246;253;253;0;0;0; 7 | 0;0;0;0;0;0;0;0;0;0;0;0;35;142;244;252;253;253;253;253;253;253;253;253;253;0;0;0; 8 | 0;0;0;0;0;0;0;0;0;0;0;0;63;253;253;253;253;253;253;253;213;170;170;170;170;0;0;0; 9 | 0;0;0;0;0;0;0;0;20;132;72;0;57;238;227;238;168;124;69;20;11;0;0;0;0;0;0;0; 10 | 0;0;0;0;0;0;0;11;206;253;78;0;0;32;0;30;2;0;0;0;0;0;0;0;0;0;0;0; 11 | 0;0;0;0;0;0;6;177;253;132;10;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 12 | 0;0;0;0;0;12;133;253;233;15;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 13 | 0;0;0;0;0;92;253;223;28;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 14 | 0;0;0;0;0;150;253;174;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 15 | 0;0;0;0;0;234;253;246;127;49;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 16 | 0;0;0;0;0;255;253;253;253;251;147;91;121;85;42;42;85;28;0;0;0;0;0;0;0;0;0;0; 17 | 0;0;0;0;0;139;253;253;253;253;253;253;253;253;253;253;253;232;168;0;0;0;0;0;0;0;0;0; 18 | 0;0;0;0;0;3;53;218;222;251;253;253;253;253;253;253;253;253;252;124;0;0;0;0;0;0;0;0; 19 | 0;0;0;0;0;0;0;0;0;67;72;200;253;253;253;253;253;253;253;175;0;0;0;0;0;0;0;0; 20 | 0;0;0;0;0;0;0;0;0;0;0;120;253;249;152;51;164;253;253;175;0;0;0;0;0;0;0;0; 21 | 0;0;0;0;0;0;0;0;0;0;0;50;253;253;253;188;252;253;253;148;0;0;0;0;0;0;0;0; 22 | 0;0;0;0;0;0;0;0;0;0;0;9;167;253;253;253;253;250;175;11;0;0;0;0;0;0;0;0; 23 | 0;0;0;0;0;0;0;0;0;0;0;0;23;180;231;253;221;128;0;0;0;0;0;0;0;0;0;0; 24 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;93;149;22;0;0;0;0;0;0;0;0;0;0;0; 25 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 26 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 27 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 28 | 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; 29 | -------------------------------------------------------------------------------- /test/text_db/labels/1.dat: -------------------------------------------------------------------------------- 1 | 7 2 | -------------------------------------------------------------------------------- /test/text_db/labels/2.dat: -------------------------------------------------------------------------------- 1 | 2 2 | -------------------------------------------------------------------------------- /test/text_db/labels/3.dat: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /test/text_db/labels/4.dat: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/text_db/labels/5.dat: -------------------------------------------------------------------------------- 1 | 4 2 | -------------------------------------------------------------------------------- /test/text_db/labels/6.dat: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /test/text_db/labels/7.dat: -------------------------------------------------------------------------------- 1 | 4 2 | -------------------------------------------------------------------------------- /test/text_db/labels/8.dat: -------------------------------------------------------------------------------- 1 | 9 2 | -------------------------------------------------------------------------------- /test/text_db/labels/9.dat: -------------------------------------------------------------------------------- 1 | 5 2 | -------------------------------------------------------------------------------- /tools/compile_dyn.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | make clean > /dev/null 4 | 5 | echo "Compile 1 RBM" 6 | time make release_debug/workbench/src/compile_rbm_one.cpp.o > /dev/null 7 | time make release_debug/bin/dll_compile_rbm_one > /dev/null 8 | 9 | echo "Compile 1 Dynamic RBM" 10 | time make release_debug/workbench/src/compile_dyn_rbm_one.cpp.o > /dev/null 11 | time make release_debug/bin/dll_compile_dyn_rbm_one > /dev/null 12 | 13 | echo "Compile 1 Hybrid RBM" 14 | time make release_debug/workbench/src/compile_hybrid_rbm_one.cpp.o > /dev/null 15 | time make release_debug/bin/dll_compile_hybrid_rbm_one > /dev/null 16 | 17 | echo "Compile 5 RBMs" 18 | time make release_debug/workbench/src/compile_rbm.cpp.o > /dev/null 19 | time make release_debug/bin/dll_compile_rbm > /dev/null 20 | 21 | echo "Compile 5 Dynamic RBMs" 22 | time make release_debug/workbench/src/compile_dyn_rbm.cpp.o > /dev/null 23 | time make release_debug/bin/dll_compile_dyn_rbm > /dev/null 24 | 25 | echo "Compile 5 Hybrid RBMs" 26 | time make release_debug/workbench/src/compile_hybrid_rbm.cpp.o > /dev/null 27 | time make release_debug/bin/dll_compile_hybrid_rbm > /dev/null 28 | -------------------------------------------------------------------------------- /tools/compile_dyn_conv.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | make clean > /dev/null 4 | 5 | echo "Compile 1 CRBM" 6 | time make release_debug/workbench/src/compile_crbm_one.cpp.o > /dev/null 7 | time make release_debug/bin/dll_compile_crbm_one > /dev/null 8 | 9 | echo "Compile 1 Dynamic CRBM" 10 | time make release_debug/workbench/src/compile_dyn_crbm_one.cpp.o > /dev/null 11 | time make release_debug/bin/dll_compile_dyn_crbm_one > /dev/null 12 | 13 | echo "Compile 1 Hybrid CRBM" 14 | time make release_debug/workbench/src/compile_hybrid_crbm_one.cpp.o > /dev/null 15 | time make release_debug/bin/dll_compile_hybrid_crbm_one > /dev/null 16 | 17 | echo "Compile 5 CRBMs" 18 | time make release_debug/workbench/src/compile_crbm.cpp.o > /dev/null 19 | time make release_debug/bin/dll_compile_crbm > /dev/null 20 | 21 | echo "Compile 5 Dynamic CRBMs" 22 | time make release_debug/workbench/src/compile_dyn_crbm.cpp.o > /dev/null 23 | time make release_debug/bin/dll_compile_dyn_crbm > /dev/null 24 | 25 | echo "Compile 5 Hybrid CRBMs" 26 | time make release_debug/workbench/src/compile_hybrid_crbm.cpp.o > /dev/null 27 | time make release_debug/bin/dll_compile_hybrid_crbm > /dev/null 28 | -------------------------------------------------------------------------------- /tools/compile_memory.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | make clean 4 | 5 | max_memory="0.0" 6 | total="0.0" 7 | 8 | start=$(date "+%s.%N") 9 | 10 | for f in test/src/*.cpp 11 | do 12 | results=$(/usr/bin/time -v make debug/$f.o 2>&1) 13 | rss=$(echo "$results" | grep "Maximum resident set size" | rev | cut -d" " -f1 | rev) 14 | elapsed=$(echo "$results" | grep "Elapsed" | rev | cut -d" " -f1 | rev) 15 | memory=$(echo "scale=2; $rss/1024" | bc -l) 16 | echo "$f => $elapsed => ${memory}MB (rss:$rss)" 17 | 18 | if [ $(echo "$max_memory < $memory" | bc) -eq 1 ] 19 | then 20 | max_memory=$memory 21 | fi 22 | done 23 | 24 | end=$(date "+%s.%N") 25 | 26 | runtime=$(echo "scale=3; ($end - $start) / 1.0" | bc -l) 27 | 28 | echo "Max memory: $max_memory" 29 | echo "Total time: $runtime" 30 | -------------------------------------------------------------------------------- /tools/test_report.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | count=0 4 | total=`ls -l test_reports/ | wc -l` 5 | 6 | for file in test_reports/* 7 | do 8 | if grep -q "All tests passed" $file 9 | then 10 | # Do nothing 11 | echo -n "" 12 | else 13 | count=$count+1 14 | cat $file 15 | fi 16 | 17 | done 18 | 19 | if [[ $count == 0 ]] 20 | then 21 | echo "All tests succeeded" 22 | else 23 | echo "$count/$total failed test cases" 24 | fi 25 | -------------------------------------------------------------------------------- /view/src/crbm_mp_view.cpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #include 9 | 10 | #include "dll/rbm/conv_rbm_mp.hpp" 11 | #include "dll/ocv_visualizer.hpp" 12 | 13 | #include "mnist/mnist_reader.hpp" 14 | #include "mnist/mnist_utils.hpp" 15 | 16 | int main(int /*argc*/, char* /*argv*/ []) { 17 | dll::conv_rbm_mp_desc_square< 18 | 1, 28, 40, 17, 2, 19 | dll::momentum, 20 | dll::batch_size<50>, 21 | dll::watcher>::layer_t rbm; 22 | 23 | auto dataset = mnist::read_dataset(); 24 | 25 | dataset.training_images.resize(500); 26 | dataset.training_labels.resize(500); 27 | 28 | mnist::normalize_dataset(dataset); 29 | 30 | rbm.train(dataset.training_images, 500); 31 | 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /view/src/crbm_view.cpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #include 9 | 10 | #include "dll/rbm/conv_rbm.hpp" 11 | #include "dll/ocv_visualizer.hpp" 12 | 13 | #include "mnist/mnist_reader.hpp" 14 | #include "mnist/mnist_utils.hpp" 15 | 16 | int main(int /*argc*/, char* /*argv*/ []) { 17 | dll::conv_rbm_square_desc< 18 | 1, 28, 40, 17, 19 | dll::momentum, 20 | dll::batch_size<50>, 21 | dll::sparsity, 22 | dll::watcher>::layer_t rbm; 23 | 24 | auto dataset = mnist::read_dataset(); 25 | 26 | dataset.training_images.resize(500); 27 | dataset.training_labels.resize(500); 28 | 29 | mnist::binarize_dataset(dataset); 30 | 31 | rbm.train(dataset.training_images, 500); 32 | 33 | return 0; 34 | } 35 | -------------------------------------------------------------------------------- /view/src/rbm_view.cpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #include 9 | 10 | #include "dll/rbm/rbm.hpp" 11 | #include "dll/ocv_visualizer.hpp" 12 | 13 | #include "mnist/mnist_reader.hpp" 14 | #include "mnist/mnist_utils.hpp" 15 | 16 | int main(int /*argc*/, char* /*argv*/ []) { 17 | dll::rbm_desc< 18 | 28 * 28, 10 * 10, 19 | dll::momentum, 20 | dll::trainer_rbm, 21 | dll::batch_size<50>, 22 | dll::visible, 23 | dll::watcher>::layer_t rbm; 24 | 25 | auto dataset = mnist::read_dataset_direct>(); 26 | 27 | mnist::normalize_dataset(dataset); 28 | 29 | rbm.train(dataset.training_images, 500); 30 | 31 | return 0; 32 | } 33 | -------------------------------------------------------------------------------- /workbench/src/cifar10_cnn_med_perf.cpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2016 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #define ETL_COUNTERS 9 | #define ETL_GPU_POOL 10 | 11 | #include "dll/neural/conv/conv_layer.hpp" 12 | #include "dll/neural/dense/dense_layer.hpp" 13 | #include "dll/pooling/mp_layer.hpp" 14 | #include "dll/network.hpp" 15 | #include "dll/datasets.hpp" 16 | 17 | int main(int /*argc*/, char* /*argv*/ []) { 18 | // Load the dataset 19 | auto dataset = dll::make_cifar10_dataset(dll::batch_size<256>{}, dll::scale_pre<255>{}); 20 | 21 | using network_t = dll::network_desc< 22 | dll::network_layers< 23 | dll::conv_layer<3, 32, 32, 12, 3, 3, dll::relu>, 24 | dll::conv_layer<12, 30, 30, 12, 3, 3, dll::relu>, 25 | dll::mp_3d_layer<12, 28, 28, 1, 2, 2>, 26 | dll::conv_layer<12, 14, 14, 24, 3, 3, dll::relu>, 27 | dll::conv_layer<24, 12, 12, 24, 3, 3, dll::relu>, 28 | dll::mp_3d_layer<24, 10, 10, 1, 2, 2>, 29 | dll::dense_layer<24 * 5 * 5, 64, dll::relu>, 30 | dll::dense_layer<64, 10, dll::softmax> 31 | >, 32 | dll::updater, 33 | dll::batch_size<256>, 34 | dll::no_batch_display, 35 | dll::no_epoch_error 36 | >::network_t; 37 | 38 | auto net = std::make_unique(); 39 | 40 | // Display the network and dataset 41 | net->display_pretty(); 42 | dataset.display_pretty(); 43 | 44 | // Train the network 45 | net->train(dataset.train(), 5); 46 | 47 | // Test the network on test set 48 | net->evaluate(dataset.test()); 49 | 50 | // Show where the time was spent 51 | dll::dump_timers_pretty(); 52 | 53 | // Show ETL performance counters 54 | etl::dump_counters_pretty(); 55 | 56 | return 0; 57 | } 58 | -------------------------------------------------------------------------------- /workbench/src/cifar10_cnn_small_perf.cpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2020 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #define ETL_COUNTERS 9 | #define ETL_GPU_POOL 10 | 11 | #include "dll/neural/conv/conv_layer.hpp" 12 | #include "dll/neural/dense/dense_layer.hpp" 13 | #include "dll/pooling/mp_layer.hpp" 14 | #include "dll/network.hpp" 15 | #include "dll/datasets.hpp" 16 | 17 | int main(int /*argc*/, char* /*argv*/ []) { 18 | // Load the dataset 19 | auto dataset = dll::make_cifar10_dataset(dll::batch_size<256>{}, dll::scale_pre<255>{}); 20 | 21 | using network_t = dll::network_desc< 22 | dll::network_layers< 23 | dll::conv_layer<3, 32, 32, 12, 5, 5, dll::relu>, 24 | dll::mp_3d_layer<12, 28, 28, 1, 2, 2>, 25 | dll::conv_layer<12, 14, 14, 24, 3, 3, dll::relu>, 26 | dll::mp_3d_layer<24, 12, 12, 1, 2, 2>, 27 | dll::dense_layer<24 * 6 * 6, 64, dll::relu>, 28 | dll::dense_layer<64, 10, dll::softmax> 29 | >, 30 | dll::updater, 31 | dll::batch_size<256>, 32 | dll::no_batch_display, 33 | dll::no_epoch_error 34 | >::network_t; 35 | 36 | auto net = std::make_unique(); 37 | 38 | // Display the network and dataset 39 | net->display_pretty(); 40 | dataset.display_pretty(); 41 | 42 | // Train the network 43 | net->train(dataset.train(), 5); 44 | 45 | // Test the network on test set 46 | net->evaluate(dataset.test()); 47 | 48 | // Show where the time was spent 49 | dll::dump_timers_pretty(); 50 | 51 | // Show ETL performance counters 52 | etl::dump_counters_pretty(); 53 | 54 | return 0; 55 | } 56 | -------------------------------------------------------------------------------- /workbench/src/compile_dyn_rbm.cpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #include 9 | #include 10 | 11 | #include "dll/rbm/dyn_rbm.hpp" 12 | #include "dll/dbn.hpp" 13 | 14 | #include "mnist/mnist_reader.hpp" 15 | #include "mnist/mnist_utils.hpp" 16 | 17 | // 5 3-layer networks 18 | 19 | int main(int, char**) { 20 | auto dataset = mnist::read_dataset_direct>(); 21 | 22 | mnist::binarize_dataset(dataset); 23 | 24 | using dbn3_t = 25 | dll::dbn_desc< 26 | dll::dbn_layers< 27 | dll::dyn_rbm_desc::layer_t, 28 | dll::dyn_rbm_desc::layer_t, 29 | dll::dyn_rbm_desc>::layer_t>, 30 | dll::batch_size<64>, dll::trainer>::dbn_t; 31 | 32 | #define decl_dbn3(NAME, F) \ 33 | auto NAME = std::make_unique(); \ 34 | NAME->template layer_get<0>().init_layer(28 * 28, 500 + F); \ 35 | NAME->template layer_get<1>().init_layer(500 + F, 400 + F); \ 36 | NAME->template layer_get<2>().init_layer(400 + F, 10); \ 37 | NAME->template layer_get<0>().batch_size = 64; \ 38 | NAME->template layer_get<1>().batch_size = 64; \ 39 | NAME->template layer_get<2>().batch_size = 64; \ 40 | NAME->pretrain(dataset.training_images, 10); \ 41 | NAME->fine_tune(dataset.training_images, dataset.training_labels, 10); 42 | 43 | decl_dbn3(dbn1,1) 44 | decl_dbn3(dbn2,2) 45 | decl_dbn3(dbn3,3) 46 | decl_dbn3(dbn4,4) 47 | decl_dbn3(dbn5,5) 48 | 49 | return 0; 50 | } 51 | -------------------------------------------------------------------------------- /workbench/src/compile_dyn_rbm_one.cpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #include 9 | #include 10 | 11 | #include "dll/rbm/dyn_rbm.hpp" 12 | #include "dll/dbn.hpp" 13 | 14 | #include "mnist/mnist_reader.hpp" 15 | #include "mnist/mnist_utils.hpp" 16 | 17 | // 1 3-layer networks 18 | 19 | int main(int, char**) { 20 | auto dataset = mnist::read_dataset_direct>(); 21 | 22 | mnist::binarize_dataset(dataset); 23 | 24 | using dbn3_t = 25 | dll::dbn_desc< 26 | dll::dbn_layers< 27 | dll::dyn_rbm_desc::layer_t, 28 | dll::dyn_rbm_desc::layer_t, 29 | dll::dyn_rbm_desc>::layer_t>, 30 | dll::batch_size<64>, dll::trainer>::dbn_t; 31 | 32 | #define decl_dbn3(NAME, F) \ 33 | auto NAME = std::make_unique(); \ 34 | NAME->template layer_get<0>().init_layer(28 * 28, 500 + F); \ 35 | NAME->template layer_get<1>().init_layer(500 + F, 400 + F); \ 36 | NAME->template layer_get<2>().init_layer(400 + F, 10); \ 37 | NAME->template layer_get<0>().batch_size = 64; \ 38 | NAME->template layer_get<1>().batch_size = 64; \ 39 | NAME->template layer_get<2>().batch_size = 64; \ 40 | NAME->pretrain(dataset.training_images, 10); \ 41 | NAME->fine_tune(dataset.training_images, dataset.training_labels, 10); 42 | 43 | decl_dbn3(dbn1,1) 44 | 45 | return 0; 46 | } 47 | -------------------------------------------------------------------------------- /workbench/src/mnist_ae_perf.cpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #define ETL_COUNTERS 9 | #define ETL_GPU_POOL 10 | 11 | #include "dll/neural/dense/dense_layer.hpp" 12 | #include "dll/network.hpp" 13 | #include "dll/datasets.hpp" 14 | 15 | #include "mnist/mnist_reader.hpp" 16 | #include "mnist/mnist_utils.hpp" 17 | 18 | int main(int /*argc*/, char* /*argv*/ []) { 19 | // Load the dataset 20 | auto dataset = dll::make_mnist_ae_dataset(dll::batch_size<256>{}, dll::scale_pre<255>{}); 21 | 22 | // Build the network 23 | 24 | using network_t = dll::network_desc< 25 | dll::network_layers< 26 | dll::dense_layer<28 * 28, 128, dll::relu>, 27 | dll::dense_layer<128, 28 * 28, dll::sigmoid> 28 | > 29 | , dll::batch_size<256> // The mini-batch size 30 | , dll::shuffle // Shuffle the dataset before each epoch 31 | , dll::binary_cross_entropy // Use a Binary Cross Entropy Loss 32 | , dll::adadelta // Adadelta updates for gradient descent 33 | , dll::no_batch_display // Disable pretty print of each every batch 34 | , dll::no_epoch_error // Disable computation of the error at each epoch 35 | >::network_t; 36 | 37 | auto net = std::make_unique(); 38 | 39 | // Display the network and dataset 40 | net->display_pretty(); 41 | dataset.display_pretty(); 42 | 43 | // Train the network as auto-encoder 44 | net->train_ae(dataset.train(), 10); 45 | 46 | // Test the network on test set 47 | net->evaluate_ae(dataset.test()); 48 | 49 | // Show where the time was spent 50 | dll::dump_timers_pretty(); 51 | 52 | // Show ETL performance counters 53 | etl::dump_counters_pretty(); 54 | 55 | return 0; 56 | } 57 | -------------------------------------------------------------------------------- /workbench/src/sgd_perf.cpp: -------------------------------------------------------------------------------- 1 | //======================================================================= 2 | // Copyright (c) 2014-2023 Baptiste Wicht 3 | // Distributed under the terms of the MIT License. 4 | // (See accompanying file LICENSE or copy at 5 | // http://opensource.org/licenses/MIT) 6 | //======================================================================= 7 | 8 | #include 9 | 10 | #define ETL_COUNTERS 11 | 12 | #include "dll/neural/dense/dense_layer.hpp" 13 | #include "dll/test.hpp" 14 | #include "dll/dbn.hpp" 15 | 16 | #include "mnist/mnist_reader.hpp" 17 | #include "mnist/mnist_utils.hpp" 18 | 19 | int main(int /*argc*/, char* /*argv*/ []) { 20 | // First experiment : Dense - Dense - Dense 21 | // Current speed on frigg: 22 | // ~20 seconds (mkl, default options) 23 | // ~13 seconds (mkl-threads, default options) 24 | 25 | auto dataset = mnist::read_dataset_direct>(); 26 | dataset.training_images.resize(10000); 27 | dataset.training_labels.resize(10000); 28 | 29 | auto n = dataset.training_images.size(); 30 | std::cout << n << " samples to test" << std::endl; 31 | 32 | mnist::binarize_dataset(dataset); 33 | 34 | using dbn_t = dll::dbn_desc< 35 | dll::dbn_layers< 36 | dll::dense_layer_desc<28 * 28, 500>::layer_t, 37 | dll::dense_layer_desc<500, 250>::layer_t, 38 | dll::dense_layer_desc<250, 10, dll::activation>::layer_t>, 39 | dll::updater, dll::batch_size<100>, dll::trainer>::dbn_t; 40 | 41 | auto net = std::make_unique(); 42 | 43 | // Train the network for performance sake 44 | net->display(); 45 | net->fine_tune(dataset.training_images, dataset.training_labels, 20); 46 | 47 | std::cout << "DLL Timers" << std::endl; 48 | dll::dump_timers(); 49 | 50 | std::cout << "ETL Counters" << std::endl; 51 | etl::dump_counters(); 52 | 53 | return 0; 54 | } 55 | --------------------------------------------------------------------------------