├── .clang-format
├── datasets
└── swissroll.zip
├── Chapter06
├── data
│ └── photo.png
├── tapkee
│ ├── util.h
│ ├── CMakeLists.txt
│ └── util.cc
└── dlib
│ └── CMakeLists.txt
├── Chapter14
└── android_detection
│ ├── app
│ ├── src
│ │ └── main
│ │ │ ├── res
│ │ │ ├── values
│ │ │ │ ├── strings.xml
│ │ │ │ ├── colors.xml
│ │ │ │ └── themes.xml
│ │ │ ├── mipmap-hdpi
│ │ │ │ ├── ic_launcher.webp
│ │ │ │ └── ic_launcher_round.webp
│ │ │ ├── mipmap-mdpi
│ │ │ │ ├── ic_launcher.webp
│ │ │ │ └── ic_launcher_round.webp
│ │ │ ├── mipmap-xhdpi
│ │ │ │ ├── ic_launcher.webp
│ │ │ │ └── ic_launcher_round.webp
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ ├── ic_launcher.webp
│ │ │ │ └── ic_launcher_round.webp
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ ├── ic_launcher.webp
│ │ │ │ └── ic_launcher_round.webp
│ │ │ ├── mipmap-anydpi-v26
│ │ │ │ ├── ic_launcher.xml
│ │ │ │ └── ic_launcher_round.xml
│ │ │ ├── layout
│ │ │ │ └── activity_main.xml
│ │ │ ├── xml
│ │ │ │ ├── backup_rules.xml
│ │ │ │ └── data_extraction_rules.xml
│ │ │ ├── values-night
│ │ │ │ └── themes.xml
│ │ │ └── drawable
│ │ │ │ └── ic_launcher_foreground.xml
│ │ │ ├── cpp
│ │ │ ├── log.h
│ │ │ ├── yolo.h
│ │ │ ├── CMakeLists.txt
│ │ │ ├── detector.h
│ │ │ └── native-lib.cpp
│ │ │ ├── assets
│ │ │ └── classes.txt
│ │ │ ├── AndroidManifest.xml
│ │ │ └── java
│ │ │ └── com
│ │ │ └── example
│ │ │ └── objectdetection
│ │ │ └── MainActivity.kt
│ ├── proguard-rules.pro
│ └── build.gradle.kts
│ ├── gradle
│ ├── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
│ └── libs.versions.toml
│ ├── build.gradle.kts
│ ├── settings.gradle.kts
│ ├── gradle.properties
│ └── gradlew.bat
├── env_scripts
├── run_container.sh
├── checkout_lib.sh
├── install_lib_custom.sh
├── install_lib.sh
├── install_android.sh
├── install_env.sh
└── dockerfile
├── Chapter02
├── json
│ ├── reviewsreader.h
│ ├── paper.h
│ ├── review.h
│ ├── CMakeLists.txt
│ └── json.cc
├── csv
│ ├── dlib
│ │ ├── CMakeLists.txt
│ │ └── csv_dlib.cc
│ ├── mlpack
│ │ ├── CMakeLists.txt
│ │ └── csv_mlpack.cc
│ ├── eigen
│ │ ├── CMakeLists.txt
│ │ └── csv.cc
│ └── flashlight
│ │ ├── CMakeLists.txt
│ │ └── csv_fl.cc
├── img
│ ├── dlib
│ │ ├── CMakeLists.txt
│ │ └── img_dlib.cc
│ └── opencv
│ │ ├── CMakeLists.txt
│ │ └── ocv.cc
└── hdf5
│ ├── CMakeLists.txt
│ └── hdf5.cc
├── Chapter12
├── onnxruntime
│ ├── model
│ │ └── refs.txt
│ └── CMakeLists.txt
├── dlib
│ ├── CMakeLists.txt
│ └── dlib-save.cc
├── flashlight
│ ├── CMakeLists.txt
│ └── fl_save.cc
├── pytorch
│ └── CMakeLists.txt
└── mlpack
│ ├── CMakeLists.txt
│ ├── cmake
│ └── Findmlpack.cmake
│ └── mlpack-save.cc
├── Chapter09
├── mlpack
│ ├── stacking.h
│ ├── CMakeLists.txt
│ └── cmake
│ │ └── Findmlpack.cmake
└── dlib
│ ├── CMakeLists.txt
│ └── dlib_ensemble.cc
├── Chapter10
├── pytorch
│ ├── lenet5.h
│ ├── CMakeLists.txt
│ ├── mnistdataset.h
│ ├── lenet5.cpp
│ └── mnistdataset.cpp
├── dlib
│ ├── CMakeLists.txt
│ └── mlp-dlib.cc
├── flashlight
│ ├── CMakeLists.txt
│ └── mlp_fl.cc
└── mlpack
│ ├── CMakeLists.txt
│ ├── cmake
│ └── Findmlpack.cmake
│ └── mlp_mlpack.cc
├── Chapter11
└── pytorch
│ ├── tokenizer.h
│ ├── model.h
│ ├── imdbreader.h
│ ├── imdbdataset.h
│ ├── imdbdataset.cc
│ ├── CMakeLists.txt
│ ├── model.cpp
│ ├── imdbreader.cc
│ ├── tokenizer.cc
│ ├── export.py
│ └── main.cpp
├── .gitignore
├── Chapter08
├── eigen
│ ├── CMakeLists.txt
│ └── data_loader.h
└── mlpack
│ ├── CMakeLists.txt
│ ├── cmake
│ └── Findmlpack.cmake
│ └── mlpack_recommender.cc
├── Chapter01
├── arrayfire_samples
│ ├── CMakeLists.txt
│ ├── linreg_af.cc
│ └── linalg_af.cc
├── dlib_samples
│ ├── CMakeLists.txt
│ ├── linreg_dlib.cc
│ └── linalg_dlib.cc
├── blaze_samples
│ ├── CMakeLists.txt
│ ├── linreg_blaze.cc
│ └── linalg_blaze.cc
├── xtensor_samples
│ ├── CMakeLists.txt
│ └── linalg_xtensor.cc
└── eigen_samples
│ ├── CMakeLists.txt
│ ├── linreg_eigen.cc
│ └── linalg_eigen.cc
├── Chapter13
└── flashlight
│ ├── CMakeLists.txt
│ ├── mlflow.h
│ ├── mlflow.cc
│ └── fl_track.cc
├── Chapter03
├── dlib
│ └── CMakeLists.txt
├── flashlight
│ ├── CMakeLists.txt
│ └── search_optuna.py
└── mlpack
│ ├── CMakeLists.txt
│ ├── cmake
│ └── Findmlpack.cmake
│ └── grid-mlpack.cc
├── Chapter04
├── dlib
│ └── CMakeLists.txt
└── mlpack
│ ├── CMakeLists.txt
│ └── cmake
│ └── Findmlpack.cmake
├── Chapter05
├── dlib
│ └── CMakeLists.txt
├── mlpack
│ ├── CMakeLists.txt
│ └── cmake
│ │ └── Findmlpack.cmake
└── data
│ ├── multivar.csv
│ └── univar.csv
├── Chapter07
├── dlib
│ └── CMakeLists.txt
├── mlpack
│ ├── CMakeLists.txt
│ └── cmake
│ │ └── Findmlpack.cmake
└── flashlight
│ └── CMakeLists.txt
├── LICENSE
└── README.md
/.clang-format:
--------------------------------------------------------------------------------
1 | BasedOnStyle: Chromium
2 | IndentWidth: 2
3 | ColumnLimit: 0
4 |
--------------------------------------------------------------------------------
/datasets/swissroll.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Hands-on-Machine-learning-with-C-Second-Edition/HEAD/datasets/swissroll.zip
--------------------------------------------------------------------------------
/Chapter06/data/photo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Hands-on-Machine-learning-with-C-Second-Edition/HEAD/Chapter06/data/photo.png
--------------------------------------------------------------------------------
/Chapter14/android_detection/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | ObjectDetection
3 |
--------------------------------------------------------------------------------
/Chapter06/tapkee/util.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | #include
4 |
5 | tapkee::DenseMatrix read_data(const std::string& file_name, char delimiter);
6 |
--------------------------------------------------------------------------------
/env_scripts/run_container.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | xhost +local:root
3 | docker run --net=host -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix -it -v $PWD/..:/samples buildenv:1.0 bash
4 |
5 |
--------------------------------------------------------------------------------
/Chapter02/json/reviewsreader.h:
--------------------------------------------------------------------------------
1 | #ifndef REVIEWSREADER_H
2 | #define REVIEWSREADER_H
3 |
4 | #include "paper.h"
5 |
6 | Papers ReadPapersReviews(const std::string& filename);
7 |
8 | #endif // REVIEWSREADER_H
9 |
--------------------------------------------------------------------------------
/Chapter14/android_detection/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Hands-on-Machine-learning-with-C-Second-Edition/HEAD/Chapter14/android_detection/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/Chapter12/onnxruntime/model/refs.txt:
--------------------------------------------------------------------------------
1 | https://github.com/onnx/models/blob/main/validated/vision/classification/synset.txt
2 | https://github.com/onnx/models/blob/main/validated/vision/classification/resnet/model/resnet50-v1-7.onnx
3 |
--------------------------------------------------------------------------------
/Chapter14/android_detection/app/src/main/res/mipmap-hdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Hands-on-Machine-learning-with-C-Second-Edition/HEAD/Chapter14/android_detection/app/src/main/res/mipmap-hdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/Chapter14/android_detection/app/src/main/res/mipmap-mdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Hands-on-Machine-learning-with-C-Second-Edition/HEAD/Chapter14/android_detection/app/src/main/res/mipmap-mdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/Chapter14/android_detection/app/src/main/res/mipmap-xhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Hands-on-Machine-learning-with-C-Second-Edition/HEAD/Chapter14/android_detection/app/src/main/res/mipmap-xhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/Chapter14/android_detection/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Hands-on-Machine-learning-with-C-Second-Edition/HEAD/Chapter14/android_detection/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/Chapter14/android_detection/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Hands-on-Machine-learning-with-C-Second-Edition/HEAD/Chapter14/android_detection/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/Chapter14/android_detection/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Hands-on-Machine-learning-with-C-Second-Edition/HEAD/Chapter14/android_detection/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/Chapter14/android_detection/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Hands-on-Machine-learning-with-C-Second-Edition/HEAD/Chapter14/android_detection/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/Chapter14/android_detection/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Hands-on-Machine-learning-with-C-Second-Edition/HEAD/Chapter14/android_detection/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/Chapter14/android_detection/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Hands-on-Machine-learning-with-C-Second-Edition/HEAD/Chapter14/android_detection/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/Chapter14/android_detection/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Hands-on-Machine-learning-with-C-Second-Edition/HEAD/Chapter14/android_detection/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/Chapter14/android_detection/build.gradle.kts:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 | plugins {
3 | alias(libs.plugins.android.application) apply false
4 | alias(libs.plugins.jetbrains.kotlin.android) apply false
5 | }
--------------------------------------------------------------------------------
/Chapter14/android_detection/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Thu Jul 25 22:16:55 EEST 2024
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
5 | zipStoreBase=GRADLE_USER_HOME
6 | zipStorePath=wrapper/dists
7 |
--------------------------------------------------------------------------------
/Chapter02/json/paper.h:
--------------------------------------------------------------------------------
1 | #ifndef PAPER_H
2 | #define PAPER_H
3 |
4 | #include "review.h"
5 |
6 | #include
7 |
8 | struct Paper {
9 | uint32_t id{0};
10 | std::string preliminary_decision;
11 | std::vector reviews;
12 | };
13 |
14 | using Papers = std::vector;
15 |
16 | #endif // PAPER_H
17 |
--------------------------------------------------------------------------------
/env_scripts/checkout_lib.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | set -x
3 | set -e
4 |
5 | START_DIR=$(pwd)
6 | REPOSITORY=$1
7 | COMMIT_HASH=$2
8 |
9 | cd $START_DIR/libs/sources
10 | git clone $REPOSITORY
11 | cd "$(basename "$REPOSITORY" .git)"
12 | git checkout $COMMIT_HASH
13 | git submodule update --init --recursive
14 | cd $START_DIR
15 |
--------------------------------------------------------------------------------
/Chapter02/json/review.h:
--------------------------------------------------------------------------------
1 | #ifndef REVIEW_H
2 | #define REVIEW_H
3 |
4 | #include
5 |
6 | struct Review {
7 | std::string confidence;
8 | std::string evaluation;
9 | uint32_t id{0};
10 | std::string language;
11 | std::string orientation;
12 | std::string remarks;
13 | std::string text;
14 | std::string timespan;
15 | };
16 |
17 | #endif // REVIEW_H
18 |
--------------------------------------------------------------------------------
/Chapter09/mlpack/stacking.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | void StackingClassification(size_t num_classes,
6 | const arma::mat& train_input,
7 | const arma::Row& train_labels,
8 | const arma::mat& test_input,
9 | const arma::Row& test_labels);
--------------------------------------------------------------------------------
/Chapter10/pytorch/lenet5.h:
--------------------------------------------------------------------------------
1 | #ifndef LENET5_H
2 | #define LENET5_H
3 |
4 | #include
5 |
6 | class LeNet5Impl : public torch::nn::Module {
7 | public:
8 | LeNet5Impl();
9 |
10 | torch::Tensor forward(torch::Tensor x);
11 |
12 | private:
13 | torch::nn::Sequential conv_;
14 | torch::nn::Sequential full_;
15 | };
16 |
17 | TORCH_MODULE(LeNet5);
18 |
19 | #endif // LENET5_H
20 |
--------------------------------------------------------------------------------
/Chapter14/android_detection/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/Chapter14/android_detection/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/Chapter11/pytorch/tokenizer.h:
--------------------------------------------------------------------------------
1 |
2 | #pragma once
3 |
4 | #include
5 |
6 | #include
7 | #include
8 |
9 | class Tokenizer {
10 | public:
11 | Tokenizer(const std::string& vocab_file_path, int max_len = 128);
12 |
13 | std::pair tokenize(const std::string text);
14 |
15 | private:
16 | std::unordered_map vocab_;
17 | int max_len_{0};
18 | };
19 |
--------------------------------------------------------------------------------
/Chapter14/android_detection/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/Chapter14/android_detection/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FFBB86FC
4 | #FF6200EE
5 | #FF3700B3
6 | #FF03DAC5
7 | #FF018786
8 | #FF000000
9 | #FFFFFFFF
10 |
--------------------------------------------------------------------------------
/Chapter11/pytorch/model.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 |
6 | class ModelImpl : public torch::nn::Module {
7 | public:
8 | ModelImpl() = delete;
9 | ModelImpl(const std::string& bert_model_path);
10 |
11 | torch::Tensor forward(at::Tensor input_ids, at::Tensor attention_masks);
12 |
13 | private:
14 | torch::jit::script::Module bert_;
15 | torch::nn::Dropout dropout_;
16 | torch::nn::Linear fc1_;
17 | torch::nn::Linear fc2_;
18 | };
19 |
20 | TORCH_MODULE(Model);
21 |
--------------------------------------------------------------------------------
/env_scripts/install_lib_custom.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | set -x
3 | set -e
4 |
5 | START_DIR=$(pwd)
6 | REPOSITORY=$1
7 | COMMIT_HASH=$2
8 | shift; shift;
9 | EXTRA_COMMAND=$@
10 |
11 | cd $START_DIR/libs/sources
12 | git clone $REPOSITORY
13 | cd "$(basename "$REPOSITORY" .git)"
14 | git checkout $COMMIT_HASH
15 |
16 | if [ -f ".gitmodules" ];then
17 | sed -i 's/git:\/\//https:\/\//g' ".gitmodules"
18 | fi
19 |
20 | git submodule update --init --recursive
21 | $EXTRA_COMMAND
22 | cd ..
23 | rm -rf build
24 | cd $START_DIR
25 |
26 |
--------------------------------------------------------------------------------
/Chapter14/android_detection/app/src/main/res/xml/backup_rules.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
13 |
--------------------------------------------------------------------------------
/Chapter14/android_detection/app/src/main/cpp/log.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 |
4 | #define LOG_TAG "OBJECT-DETECTION"
5 | #define LOGI(...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)
6 | #define LOGW(...) __android_log_print(ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__)
7 | #define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)
8 | #define ASSERT(cond, fmt, ...) \
9 | if (!(cond)) { \
10 | __android_log_assert(#cond, LOG_TAG, fmt, ##__VA_ARGS__); \
11 | }
12 |
--------------------------------------------------------------------------------
/Chapter11/pytorch/imdbreader.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 |
6 | class ImdbReader {
7 | public:
8 | ImdbReader(const std::string& root_path);
9 |
10 | size_t get_pos_size() const;
11 | size_t get_neg_size() const;
12 |
13 | const std::string& get_pos(size_t index) const;
14 | const std::string& get_neg(size_t index) const;
15 |
16 | private:
17 | using Reviews = std::vector;
18 |
19 | void read_directory(const std::string& path, Reviews& reviews);
20 |
21 | private:
22 | Reviews pos_samples_;
23 | Reviews neg_samples_;
24 | size_t max_size_{0};
25 | };
26 |
--------------------------------------------------------------------------------
/Chapter02/csv/dlib/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.22)
2 | project(csv-dlib)
3 |
4 | find_package(dlib 19.24 REQUIRED)
5 |
6 | set(CMAKE_CXX_STANDARD_REQUIRED ON)
7 | set(CMAKE_CXX_STANDARD 20)
8 | set(CMAKE_CXX_EXTENSIONS OFF)
9 |
10 | set(CMAKE_VERBOSE_MAKEFILE ON)
11 |
12 | add_compile_options(
13 | -Wall -Wextra -msse3 -fopenmp
14 | $<$:-Ofast>
15 | $<$:-O0>
16 | $<$:-ggdb3>
17 | )
18 |
19 | add_compile_definitions(
20 | $<$:NDEBUG>
21 | )
22 |
23 | add_executable(csv-dlib "csv_dlib.cc")
24 | target_link_libraries(csv-dlib dlib::dlib)
25 |
--------------------------------------------------------------------------------
/Chapter02/img/dlib/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.22)
2 | project(img-dlib)
3 |
4 | find_package(dlib 19.24 REQUIRED)
5 |
6 | set(CMAKE_CXX_STANDARD_REQUIRED ON)
7 | set(CMAKE_CXX_STANDARD 20)
8 | set(CMAKE_CXX_EXTENSIONS OFF)
9 |
10 | set(CMAKE_VERBOSE_MAKEFILE ON)
11 |
12 | add_compile_options(
13 | -Wall -Wextra -msse3 -fopenmp
14 | $<$:-Ofast>
15 | $<$:-O0>
16 | $<$:-ggdb3>
17 | )
18 |
19 | add_compile_definitions(
20 | $<$:NDEBUG>
21 | )
22 |
23 | add_executable(img-dlib "img_dlib.cc")
24 | target_link_libraries(img-dlib dlib::dlib)
25 |
--------------------------------------------------------------------------------
/env_scripts/install_lib.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | set -x
3 | set -e
4 |
5 | START_DIR=$(pwd)
6 | REPOSITORY=$1
7 | COMMIT_HASH=$2
8 | shift; shift;
9 | EXTRA_CMAKE_PARAMS=$@
10 |
11 | cd $START_DIR/libs/sources
12 | git clone $REPOSITORY
13 | cd "$(basename "$REPOSITORY" .git)"
14 | git checkout $COMMIT_HASH
15 |
16 | if [ -f ".gitmodules" ];then
17 | sed -i 's/git:\/\//https:\/\//g' ".gitmodules"
18 | fi
19 |
20 | git submodule update --init --recursive
21 | mkdir build
22 | cd build
23 | cmake -DCMAKE_INSTALL_PREFIX=$START_DIR/libs $EXTRA_CMAKE_PARAMS ..
24 | cmake --build . --target install -- -j8
25 | cd ..
26 | rm -rf build
27 | cd $START_DIR
28 |
--------------------------------------------------------------------------------
/Chapter14/android_detection/settings.gradle.kts:
--------------------------------------------------------------------------------
1 | pluginManagement {
2 | repositories {
3 | google {
4 | content {
5 | includeGroupByRegex("com\\.android.*")
6 | includeGroupByRegex("com\\.google.*")
7 | includeGroupByRegex("androidx.*")
8 | }
9 | }
10 | mavenCentral()
11 | gradlePluginPortal()
12 | }
13 | }
14 | dependencyResolutionManagement {
15 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
16 | repositories {
17 | google()
18 | mavenCentral()
19 | }
20 | }
21 |
22 | rootProject.name = "ObjectDetection"
23 | include(":app")
24 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # VS Code settings
2 | .vscode/*
3 |
4 | # Local History for Visual Studio Code
5 | .history/
6 |
7 | # Built Visual Studio Code Extensions
8 | *.vsix
9 | *.vscode
10 |
11 | # Build folders
12 | build
13 |
14 | # data folders
15 | data
16 |
17 | # Prerequisites
18 | *.d
19 |
20 | # Compiled Object files
21 | *.slo
22 | *.lo
23 | *.o
24 | *.obj
25 |
26 | # Precompiled Headers
27 | *.gch
28 | *.pch
29 |
30 | # Compiled Dynamic libraries
31 | *.so
32 | *.dylib
33 | *.dll
34 |
35 | # Fortran module files
36 | *.mod
37 | *.smod
38 |
39 | # Compiled Static libraries
40 | *.lai
41 | *.la
42 | *.a
43 | *.lib
44 |
45 | # Executables
46 | *.exe
47 | *.out
48 | *.app
49 |
50 |
--------------------------------------------------------------------------------
/Chapter14/android_detection/app/src/main/res/xml/data_extraction_rules.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
12 |
13 |
19 |
--------------------------------------------------------------------------------
/Chapter12/dlib/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.22)
2 | project(dlib-save)
3 |
4 | find_package(dlib 19.24 REQUIRED)
5 |
6 | set(CMAKE_CXX_STANDARD_REQUIRED ON)
7 | set(CMAKE_CXX_STANDARD 20)
8 | set(CMAKE_CXX_EXTENSIONS OFF)
9 |
10 | set(CMAKE_VERBOSE_MAKEFILE ON)
11 |
12 | add_compile_options(
13 | -Wall -Wextra -msse3 -fopenmp
14 | $<$:-Ofast>
15 | $<$:-O0>
16 | $<$:-ggdb3>
17 | )
18 |
19 | add_compile_definitions(
20 | $<$:NDEBUG>
21 | )
22 |
23 | set(SOURCES
24 | dlib-save.cc
25 | )
26 |
27 | add_executable(dlib-save ${SOURCES})
28 | target_link_libraries(dlib-save dlib::dlib)
29 |
30 |
--------------------------------------------------------------------------------
/Chapter02/img/opencv/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.22)
2 | project(img-opencv)
3 |
4 | find_package(OpenCV 4.5 REQUIRED COMPONENTS core imgproc highgui)
5 |
6 | set(CMAKE_CXX_STANDARD_REQUIRED ON)
7 | set(CMAKE_CXX_STANDARD 20)
8 | set(CMAKE_CXX_EXTENSIONS OFF)
9 |
10 | set(CMAKE_VERBOSE_MAKEFILE ON)
11 |
12 | add_compile_options(
13 | -Wall -Wextra -msse3 -fopenmp
14 | $<$:-Ofast>
15 | $<$:-O0>
16 | $<$:-ggdb3>
17 | )
18 |
19 | add_compile_definitions(
20 | $<$:NDEBUG>
21 | )
22 |
23 | add_executable(img-opencv "ocv.cc")
24 | target_link_libraries(img-opencv opencv_core opencv_imgproc opencv_highgui)
25 |
--------------------------------------------------------------------------------
/Chapter10/dlib/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.22)
2 | project(dlib-mlp)
3 |
4 | find_package(dlib 19.24 REQUIRED)
5 |
6 | set(CMAKE_CXX_STANDARD_REQUIRED ON)
7 | set(CMAKE_CXX_STANDARD 20)
8 | set(CMAKE_CXX_EXTENSIONS OFF)
9 |
10 | set(CMAKE_VERBOSE_MAKEFILE ON)
11 |
12 | add_compile_options(
13 | -Wall -Wextra -msse3 -fopenmp
14 | $<$:-Ofast>
15 | $<$:-O0>
16 | $<$:-ggdb3>
17 | )
18 |
19 | add_compile_definitions(
20 | $<$:NDEBUG>
21 | )
22 |
23 | set(SOURCES
24 | mlp-dlib.cc
25 | ../data/data.h
26 | ../data/data.cc
27 | )
28 |
29 | add_executable(dlib-mlp ${SOURCES})
30 | target_link_libraries(dlib-mlp dlib::dlib)
31 |
--------------------------------------------------------------------------------
/Chapter08/eigen/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.22)
2 | project(eigen_recommender)
3 |
4 | find_package(Eigen3 3.4.0 REQUIRED)
5 |
6 | set(CMAKE_CXX_STANDARD_REQUIRED ON)
7 | set(CMAKE_CXX_STANDARD 20)
8 | set(CMAKE_CXX_EXTENSIONS OFF)
9 |
10 | set(CMAKE_VERBOSE_MAKEFILE ON)
11 |
12 | add_compile_options(
13 | -Wall -Wextra -msse3 -fopenmp
14 | $<$:-Ofast>
15 | $<$:-O0>
16 | $<$:-ggdb3>
17 | )
18 |
19 | add_compile_definitions(
20 | $<$:NDEBUG>
21 | )
22 |
23 | include_directories(${CSV_LIB_PATH})
24 |
25 | add_executable(eigen_recommender "eigen_recommender.cc")
26 | target_link_libraries (eigen_recommender Eigen3::Eigen gomp)
27 |
28 |
29 |
--------------------------------------------------------------------------------
/Chapter12/flashlight/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.10)
2 | project(fl_save)
3 |
4 | find_package(flashlight 0.4.0 REQUIRED)
5 |
6 | set(CMAKE_CXX_STANDARD_REQUIRED ON)
7 | set(CMAKE_CXX_STANDARD 20)
8 | set(CMAKE_CXX_EXTENSIONS OFF)
9 |
10 | set(CMAKE_VERBOSE_MAKEFILE ON)
11 |
12 | add_compile_options(
13 | -Wall -Wextra -msse3 -fopenmp
14 | $<$:-Ofast>
15 | $<$:-O0>
16 | $<$:-ggdb3>
17 | )
18 |
19 | add_compile_definitions(
20 | $<$:NDEBUG>
21 | )
22 |
23 | include_directories(${PLOTCPP_PATH})
24 |
25 | set(SOURCES
26 | fl_save.cc
27 | )
28 |
29 | add_executable(fl_save ${SOURCES})
30 | target_link_libraries(fl_save flashlight::flashlight)
31 |
--------------------------------------------------------------------------------
/Chapter01/arrayfire_samples/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.22)
2 | project(arrayfire_samples)
3 |
4 | find_package(ArrayFire)
5 |
6 | set(CMAKE_CXX_STANDARD_REQUIRED ON)
7 | set(CMAKE_CXX_STANDARD 20)
8 | set(CMAKE_CXX_EXTENSIONS OFF)
9 |
10 | set(CMAKE_VERBOSE_MAKEFILE ON)
11 |
12 | add_compile_options(
13 | -Wall -Wextra -msse3 -fopenmp
14 | $<$:-Ofast>
15 | $<$:-O0>
16 | $<$:-ggdb3>
17 | )
18 |
19 | add_compile_definitions(
20 | $<$:NDEBUG>
21 | )
22 |
23 | add_executable(linalg_af "linalg_af.cc")
24 | target_link_libraries(linalg_af ArrayFire::afcpu)
25 |
26 | add_executable(linreg_af "linreg_af.cc")
27 | target_link_libraries(linreg_af ArrayFire::afcpu)
28 |
29 |
--------------------------------------------------------------------------------
/Chapter01/dlib_samples/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.22)
2 | project(dlib-samples)
3 |
4 | find_package(dlib 19.24 REQUIRED)
5 |
6 | set(CMAKE_CXX_STANDARD_REQUIRED ON)
7 | set(CMAKE_CXX_STANDARD 20)
8 | set(CMAKE_CXX_EXTENSIONS OFF)
9 |
10 | set(CMAKE_VERBOSE_MAKEFILE ON)
11 |
12 | add_compile_options(
13 | -Wall -Wextra -msse3 -fopenmp
14 | $<$:-Ofast>
15 | $<$:-O0>
16 | $<$:-ggdb3>
17 | )
18 |
19 | add_compile_definitions(
20 | $<$:NDEBUG>
21 | )
22 |
23 | add_executable(linalg-dlib "linalg_dlib.cc")
24 | target_link_libraries(linalg-dlib dlib::dlib)
25 |
26 | add_executable(linreg-dlib "linreg_dlib.cc")
27 | target_link_libraries(linreg-dlib dlib::dlib)
28 |
29 |
--------------------------------------------------------------------------------
/Chapter12/pytorch/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.22)
2 | project(pytorch-save)
3 |
4 | find_package(Torch REQUIRED)
5 | find_package(OpenCV REQUIRED)
6 |
7 | set(CMAKE_VERBOSE_MAKEFILE ON)
8 | set(CMAKE_CXX_STANDARD_REQUIRED ON)
9 | set(CMAKE_CXX_STANDARD 20)
10 | set(CMAKE_CXX_EXTENSIONS OFF)
11 |
12 |
13 | include_directories(${TORCH_INCLUDE_DIRS})
14 |
15 | add_compile_options(
16 | -Wall -Wextra -msse3 -fopenmp
17 | $<$:-Ofast>
18 | $<$:-O0>
19 | $<$:-ggdb3>
20 | )
21 |
22 | set(SOURCE_FILES main.cc)
23 |
24 | add_executable("${CMAKE_PROJECT_NAME}" ${SOURCE_FILES})
25 | target_link_libraries("${CMAKE_PROJECT_NAME}" ${TORCH_LIBRARIES} ${OpenCV_LIBS})
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/Chapter13/flashlight/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.10)
2 | project(fl_track)
3 |
4 | find_package(flashlight 0.4.0 REQUIRED)
5 |
6 | set(CMAKE_CXX_STANDARD_REQUIRED ON)
7 | set(CMAKE_CXX_STANDARD 20)
8 | set(CMAKE_CXX_EXTENSIONS OFF)
9 |
10 | set(CMAKE_VERBOSE_MAKEFILE ON)
11 |
12 | add_compile_options(
13 | -Wall -Wextra -msse3 -fopenmp
14 | $<$:-Ofast>
15 | $<$:-O0>
16 | $<$:-ggdb3>
17 | )
18 |
19 | add_compile_definitions(
20 | $<$:NDEBUG>
21 | )
22 |
23 | include_directories(${PLOTCPP_PATH})
24 |
25 | set(SOURCES
26 | fl_track.cc
27 | mlflow.cc
28 | )
29 |
30 | add_executable(fl_track ${SOURCES})
31 | target_link_libraries(fl_track flashlight::flashlight)
32 |
--------------------------------------------------------------------------------
/Chapter01/blaze_samples/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.22)
2 | project(blaze_samples)
3 |
4 | find_package(blaze 3.8.2 REQUIRED)
5 |
6 | set(CMAKE_CXX_STANDARD_REQUIRED ON)
7 | set(CMAKE_CXX_STANDARD 20)
8 | set(CMAKE_CXX_EXTENSIONS OFF)
9 |
10 | set(CMAKE_VERBOSE_MAKEFILE ON)
11 |
12 | add_compile_options(
13 | -Wall -Wextra -msse3 -fopenmp
14 | $<$:-Ofast>
15 | $<$:-O0>
16 | $<$:-ggdb3>
17 | )
18 |
19 | add_compile_definitions(
20 | $<$:NDEBUG>
21 | )
22 |
23 | add_executable(linalg_blaze "linalg_blaze.cc")
24 | target_link_libraries(linalg_blaze blas lapack blaze::blaze)
25 |
26 | add_executable(linreg_blaze "linreg_blaze.cc")
27 | target_link_libraries(linreg_blaze blas lapack blaze::blaze)
28 |
29 |
--------------------------------------------------------------------------------
/Chapter01/xtensor_samples/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.22)
2 | project(xtensor_samples)
3 |
4 | find_package(xtensor 0.24.5 REQUIRED)
5 | find_package(xtensor-blas 0.20.0 REQUIRED)
6 |
7 | set(CMAKE_CXX_STANDARD_REQUIRED ON)
8 | set(CMAKE_CXX_STANDARD 20)
9 | set(CMAKE_CXX_EXTENSIONS OFF)
10 |
11 | set(CMAKE_VERBOSE_MAKEFILE ON)
12 |
13 | add_compile_options(
14 | -Wall -Wextra -msse3
15 | $<$:-Ofast>
16 | $<$:-O0>
17 | $<$:-ggdb3>
18 | )
19 |
20 | add_compile_definitions(
21 | $<$:NDEBUG>
22 | )
23 |
24 | add_executable(linalg_xtensor "linalg_xtensor.cc")
25 | target_include_directories(linalg_xtensor PRIVATE ${xtensor_INCLUDE_DIRS})
26 | target_link_libraries(linalg_xtensor blas)
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/Chapter10/flashlight/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.10)
2 | project(mlp-flashlight)
3 |
4 | find_package(flashlight 0.4.0 REQUIRED)
5 |
6 | set(CMAKE_CXX_STANDARD_REQUIRED ON)
7 | set(CMAKE_CXX_STANDARD 20)
8 | set(CMAKE_CXX_EXTENSIONS OFF)
9 |
10 | set(CMAKE_VERBOSE_MAKEFILE ON)
11 |
12 | add_compile_options(
13 | -Wall -Wextra -msse3 -fopenmp
14 | $<$:-Ofast>
15 | $<$:-O0>
16 | $<$:-ggdb3>
17 | )
18 |
19 | add_compile_definitions(
20 | $<$:NDEBUG>
21 | )
22 |
23 | include_directories(${PLOTCPP_PATH})
24 |
25 | set(SOURCES
26 | mlp_fl.cc
27 | ../data/data.h
28 | ../data/data.cc
29 | )
30 |
31 | add_executable(mlp_fl ${SOURCES})
32 | target_link_libraries(mlp_fl flashlight::flashlight)
33 |
--------------------------------------------------------------------------------
/Chapter11/pytorch/imdbdataset.h:
--------------------------------------------------------------------------------
1 | #ifndef MNISTDATASET_H
2 | #define MNISTDATASET_H
3 |
4 | #include "imdbreader.h"
5 | #include "tokenizer.h"
6 |
7 | #include
8 |
9 | #include
10 |
11 | using ImdbData = std::pair;
12 | using ImdbExample = torch::data::Example;
13 |
14 | class ImdbDataset : public torch::data::Dataset {
15 | public:
16 | ImdbDataset(const std::string& dataset_path,
17 | std::shared_ptr tokenizer);
18 |
19 | // torch::data::Dataset implementation
20 | ImdbExample get(size_t index) override;
21 | torch::optional size() const override;
22 |
23 | private:
24 | ImdbReader reader_;
25 | std::shared_ptr tokenizer_;
26 | };
27 |
28 | #endif // MNISTDATASET_H
29 |
--------------------------------------------------------------------------------
/Chapter01/eigen_samples/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.22)
2 | project(eigen_samples)
3 |
4 | find_package(OpenMP)
5 | find_package(Eigen3 3.4.0 REQUIRED)
6 |
7 | set(CMAKE_CXX_STANDARD_REQUIRED ON)
8 | set(CMAKE_CXX_STANDARD 20)
9 | set(CMAKE_CXX_EXTENSIONS OFF)
10 |
11 | set(CMAKE_VERBOSE_MAKEFILE ON)
12 |
13 | add_compile_options(
14 | -Wall -Wextra -msse3
15 | $<$:-Ofast>
16 | $<$:-O0>
17 | $<$:-ggdb3>
18 | )
19 |
20 | add_compile_definitions(
21 | $<$:NDEBUG>
22 | )
23 |
24 | add_executable(linalg_eigen "linalg_eigen.cc")
25 | target_link_libraries(linalg_eigen Eigen3::Eigen OpenMP::OpenMP_CXX)
26 |
27 | add_executable(linreg_eigen "linreg_eigen.cc")
28 | target_link_libraries(linreg_eigen Eigen3::Eigen OpenMP::OpenMP_CXX)
29 |
--------------------------------------------------------------------------------
/Chapter14/android_detection/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
--------------------------------------------------------------------------------
/Chapter12/onnxruntime/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.10)
2 | project(onnx-load)
3 |
4 | find_package(onnxruntime REQUIRED)
5 | find_package(OpenCV 4.5 REQUIRED COMPONENTS core imgproc imgcodecs)
6 |
7 | set(CMAKE_CXX_STANDARD_REQUIRED ON)
8 | set(CMAKE_CXX_STANDARD 20)
9 | set(CMAKE_CXX_EXTENSIONS OFF)
10 |
11 | set(CMAKE_VERBOSE_MAKEFILE ON)
12 |
13 | add_compile_options(
14 | -Wall -Wextra -msse3 -fopenmp
15 | $<$:-Ofast>
16 | $<$:-O0>
17 | $<$:-ggdb3>
18 | )
19 |
20 | add_compile_definitions(
21 | $<$:NDEBUG>
22 | )
23 |
24 | include_directories(${PLOTCPP_PATH})
25 |
26 | set(SOURCES
27 | main.cc
28 | )
29 |
30 | add_executable(onnx-load ${SOURCES})
31 | target_link_libraries(onnx-load onnxruntime::onnxruntime opencv_core opencv_imgproc opencv_imgcodecs)
32 |
--------------------------------------------------------------------------------
/Chapter02/json/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.22)
2 | project(json_sample)
3 |
4 | find_package(nlohmann_json 3.11.2 REQUIRED)
5 | find_package(Eigen3 3.4.0 REQUIRED)
6 |
7 | set(CMAKE_CXX_STANDARD_REQUIRED ON)
8 | set(CMAKE_CXX_STANDARD 20)
9 | set(CMAKE_CXX_EXTENSIONS OFF)
10 |
11 | set(CMAKE_VERBOSE_MAKEFILE ON)
12 |
13 | add_compile_options(
14 | -Wall -Wextra -msse3 -fopenmp
15 | $<$:-Ofast>
16 | $<$:-O0>
17 | $<$:-ggdb3>
18 | )
19 |
20 | add_compile_definitions(
21 | $<$:NDEBUG>
22 | )
23 |
24 | set(SOURCES json.cc
25 | review.h
26 | paper.h
27 | reviewsreader.h
28 | reviewsreader.cpp)
29 |
30 | add_executable(json_sample ${SOURCES})
31 | target_link_libraries(json_sample Eigen3::Eigen nlohmann_json::nlohmann_json)
32 |
--------------------------------------------------------------------------------
/Chapter10/pytorch/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.22)
2 | project(lenet-pytorch)
3 |
4 | find_package(Torch REQUIRED)
5 | find_package(OpenCV REQUIRED)
6 |
7 | set(CMAKE_VERBOSE_MAKEFILE ON)
8 | set(CMAKE_CXX_STANDARD_REQUIRED ON)
9 | set(CMAKE_CXX_STANDARD 20)
10 | set(CMAKE_CXX_EXTENSIONS OFF)
11 |
12 |
13 | include_directories(${TORCH_INCLUDE_DIRS})
14 |
15 | add_compile_options(
16 | -Wall -Wextra -msse3 -fopenmp
17 | $<$:-Ofast>
18 | $<$:-O0>
19 | $<$:-ggdb3>
20 | )
21 |
22 | set(SOURCE_FILES main.cpp
23 | mnistdataset.h
24 | mnistdataset.cpp
25 | lenet5.h
26 | lenet5.cpp)
27 |
28 | add_executable("${CMAKE_PROJECT_NAME}" ${SOURCE_FILES})
29 | target_link_libraries("${CMAKE_PROJECT_NAME}" ${TORCH_LIBRARIES} ${OpenCV_LIBS})
30 |
31 |
--------------------------------------------------------------------------------
/Chapter09/mlpack/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.10)
2 | project(mlpack-ensemble)
3 |
4 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
5 | find_package(mlpack 4.0.1 REQUIRED)
6 |
7 | set(CMAKE_CXX_STANDARD_REQUIRED ON)
8 | set(CMAKE_CXX_STANDARD 20)
9 | set(CMAKE_CXX_EXTENSIONS OFF)
10 |
11 | add_compile_options(
12 | -Wall -Wextra -msse3 -fopenmp
13 | $<$:-Ofast>
14 | $<$:-O0>
15 | $<$:-ggdb3>
16 | )
17 |
18 | add_link_options(-fopenmp)
19 |
20 | add_compile_definitions(
21 | $<$:NDEBUG>
22 | )
23 |
24 | include_directories(${MLPACK_INCLUDE_DIR})
25 |
26 | add_executable(mlpack-ensemble mlpack_ensemble.cc stacking.cc)
27 | target_link_directories(mlpack-ensemble PRIVATE ${CMAKE_PREFIX_PATH}/lib)
28 | target_link_libraries(mlpack-ensemble ${MLPACK_LIBRARIES} armadillo)
29 |
--------------------------------------------------------------------------------
/Chapter06/dlib/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.10)
2 | project(dlib-dr)
3 |
4 | find_package(dlib 19.24 REQUIRED)
5 |
6 | set(PLOTCPP_PATH "" CACHE PATH "path to poltcpp install dir")
7 |
8 | if (NOT PLOTCPP_PATH)
9 | message(FATAL_ERROR "Missigng plotcpp include path, please specify PLOTCPP_PATH")
10 | else()
11 | message("plotcpp path is ${PLOTCPP_PATH}")
12 | endif()
13 |
14 |
15 | set(CMAKE_CXX_STANDARD_REQUIRED ON)
16 | set(CMAKE_CXX_STANDARD 20)
17 | set(CMAKE_CXX_EXTENSIONS OFF)
18 |
19 | add_compile_options(
20 | -Wall -Wextra -msse3 -fopenmp
21 | $<$:-Ofast>
22 | $<$:-O0>
23 | $<$:-ggdb3>
24 | )
25 |
26 | add_compile_definitions(
27 | $<$:NDEBUG>
28 | )
29 |
30 | include_directories(${PLOTCPP_PATH})
31 |
32 | add_executable(dlib-dr "dlib-dr.cc")
33 | target_link_libraries(dlib-dr dlib::dlib)
34 |
--------------------------------------------------------------------------------
/Chapter14/android_detection/app/src/main/res/values/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
16 |
--------------------------------------------------------------------------------
/Chapter03/dlib/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.10)
2 | project(dlib-sample)
3 |
4 | find_package(dlib 19.24 REQUIRED)
5 |
6 | set(PLOTCPP_PATH "" CACHE PATH "path to poltcpp install dir")
7 |
8 | if (NOT PLOTCPP_PATH)
9 | message(FATAL_ERROR "Missigng plotcpp include path, please specify PLOTCPP_PATH")
10 | else()
11 | message("plotcpp path is ${PLOTCPP_PATH}")
12 | endif()
13 |
14 |
15 | set(CMAKE_CXX_STANDARD_REQUIRED ON)
16 | set(CMAKE_CXX_STANDARD 20)
17 | set(CMAKE_CXX_EXTENSIONS OFF)
18 |
19 | add_compile_options(
20 | -Wall -Wextra -msse3 -fopenmp
21 | $<$:-Ofast>
22 | $<$:-O0>
23 | $<$:-ggdb3>
24 | )
25 |
26 | add_compile_definitions(
27 | $<$:NDEBUG>
28 | )
29 |
30 | include_directories(${PLOTCPP_PATH})
31 |
32 | add_executable(grid-dlib "grid-dlib.cc")
33 | target_link_libraries(grid-dlib dlib::dlib)
34 |
--------------------------------------------------------------------------------
/Chapter14/android_detection/app/src/main/res/values-night/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
16 |
--------------------------------------------------------------------------------
/Chapter04/dlib/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.10)
2 | project(dlib-cluster)
3 |
4 | find_package(dlib 19.24 REQUIRED)
5 |
6 | set(PLOTCPP_PATH "" CACHE PATH "path to poltcpp install dir")
7 |
8 | if (NOT PLOTCPP_PATH)
9 | message(FATAL_ERROR "Missigng plotcpp include path, please specify PLOTCPP_PATH")
10 | else()
11 | message("plotcpp path is ${PLOTCPP_PATH}")
12 | endif()
13 |
14 |
15 | set(CMAKE_CXX_STANDARD_REQUIRED ON)
16 | set(CMAKE_CXX_STANDARD 20)
17 | set(CMAKE_CXX_EXTENSIONS OFF)
18 |
19 | add_compile_options(
20 | -Wall -Wextra -msse3 -fopenmp
21 | $<$:-Ofast>
22 | $<$:-O0>
23 | $<$:-ggdb3>
24 | )
25 |
26 | add_compile_definitions(
27 | $<$:NDEBUG>
28 | )
29 |
30 | include_directories(${PLOTCPP_PATH})
31 |
32 | add_executable(dlib-cluster "dlib-cluster.cc")
33 | target_link_libraries(dlib-cluster dlib::dlib)
34 |
--------------------------------------------------------------------------------
/Chapter05/dlib/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.10)
2 | project(dlib-anomaly)
3 |
4 | find_package(dlib 19.24 REQUIRED)
5 |
6 | set(PLOTCPP_PATH "" CACHE PATH "path to poltcpp install dir")
7 |
8 | if (NOT PLOTCPP_PATH)
9 | message(FATAL_ERROR "Missigng plotcpp include path, please specify PLOTCPP_PATH")
10 | else()
11 | message("plotcpp path is ${PLOTCPP_PATH}")
12 | endif()
13 |
14 |
15 | set(CMAKE_CXX_STANDARD_REQUIRED ON)
16 | set(CMAKE_CXX_STANDARD 20)
17 | set(CMAKE_CXX_EXTENSIONS OFF)
18 |
19 | add_compile_options(
20 | -Wall -Wextra -msse3 -fopenmp
21 | $<$:-Ofast>
22 | $<$:-O0>
23 | $<$:-ggdb3>
24 | )
25 |
26 | add_compile_definitions(
27 | $<$:NDEBUG>
28 | )
29 |
30 | include_directories(${PLOTCPP_PATH})
31 |
32 | add_executable(dlib-anomaly "dlib-anomaly.cc")
33 | target_link_libraries(dlib-anomaly dlib::dlib)
34 |
--------------------------------------------------------------------------------
/Chapter07/dlib/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.10)
2 | project(dlib-classify)
3 |
4 | find_package(dlib 19.24 REQUIRED)
5 |
6 | set(PLOTCPP_PATH "" CACHE PATH "path to poltcpp install dir")
7 |
8 | if (NOT PLOTCPP_PATH)
9 | message(FATAL_ERROR "Missigng plotcpp include path, please specify PLOTCPP_PATH")
10 | else()
11 | message("plotcpp path is ${PLOTCPP_PATH}")
12 | endif()
13 |
14 |
15 | set(CMAKE_CXX_STANDARD_REQUIRED ON)
16 | set(CMAKE_CXX_STANDARD 20)
17 | set(CMAKE_CXX_EXTENSIONS OFF)
18 |
19 | add_compile_options(
20 | -Wall -Wextra -msse3 -fopenmp
21 | $<$:-Ofast>
22 | $<$:-O0>
23 | $<$:-ggdb3>
24 | )
25 |
26 | add_compile_definitions(
27 | $<$:NDEBUG>
28 | )
29 |
30 | include_directories(${PLOTCPP_PATH})
31 |
32 | add_executable(dlib-classify "dlib-classify.cc")
33 | target_link_libraries(dlib-classify dlib::dlib)
34 |
--------------------------------------------------------------------------------
/Chapter02/csv/mlpack/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.0)
2 | project(mlpack-csv-sample)
3 |
4 | include(FindPackageHandleStandardArgs)
5 |
6 | find_package(OpenMP REQUIRED)
7 |
8 | find_path(MLPACK_INCLUDE_DIR
9 | NAMES mlpack/core.hpp mlpack/prereqs.hpp
10 | )
11 |
12 | find_package_handle_standard_args(mlpack
13 | REQUIRED_VARS MLPACK_INCLUDE_DIR
14 | )
15 |
16 | set(CMAKE_CXX_STANDARD_REQUIRED ON)
17 | set(CMAKE_CXX_STANDARD 20)
18 | set(CMAKE_CXX_EXTENSIONS OFF)
19 |
20 | set(CMAKE_VERBOSE_MAKEFILE ON)
21 |
22 | add_compile_options(
23 | -Wall -Wextra -msse3 -fopenmp
24 | $<$:-Ofast>
25 | $<$:-O0>
26 | $<$:-ggdb3>
27 | )
28 |
29 | add_compile_definitions(
30 | $<$:NDEBUG>
31 | )
32 |
33 | include_directories(${MLPACK_INCLUDE_DIR})
34 |
35 | add_executable(csv_mlpack csv_mlpack.cc)
36 | target_link_libraries(csv_mlpack OpenMP::OpenMP_CXX)
--------------------------------------------------------------------------------
/Chapter02/hdf5/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.0)
2 | project(hdf5_sample)
3 |
4 | find_package(HDF5 1.10.7 REQUIRED)
5 | find_package(HighFive 2.7.0 REQUIRED)
6 | find_package(nlohmann_json 3.11.2 REQUIRED)
7 |
8 | set(CMAKE_CXX_STANDARD_REQUIRED ON)
9 | set(CMAKE_CXX_STANDARD 20)
10 | set(CMAKE_CXX_EXTENSIONS OFF)
11 |
12 | set(CMAKE_VERBOSE_MAKEFILE ON)
13 |
14 | add_compile_options(
15 | -Wall -Wextra -msse3 -fopenmp
16 | $<$:-Ofast>
17 | $<$:-O0>
18 | $<$:-ggdb3>
19 | )
20 |
21 | add_compile_definitions(
22 | $<$:NDEBUG>
23 | )
24 |
25 | set(SOURCES hdf5.cc
26 | ../../json/paper.h
27 | ../../json/review.h
28 | ../../json/reviewsreader.h
29 | ../../json/reviewsreader.cpp)
30 |
31 | add_executable(hdf5_sample ${SOURCES})
32 | target_link_libraries(hdf5_sample nlohmann_json::nlohmann_json HighFive)
33 |
--------------------------------------------------------------------------------
/Chapter02/csv/eigen/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.22)
2 | project(csv_sample)
3 |
4 | set(CSV_LIB_PATH "" CACHE PATH "Path to csv library include dir")
5 |
6 | if (NOT CSV_LIB_PATH)
7 | message(FATAL_ERROR "Missigng CSV lib install path, please specify CSV_LIB_PATH")
8 | else()
9 | message("CSV lib path is ${CSV_LIB_PATH}")
10 | endif()
11 |
12 | find_package(Eigen3 3.4.0 REQUIRED)
13 |
14 | set(CMAKE_CXX_STANDARD_REQUIRED ON)
15 | set(CMAKE_CXX_STANDARD 20)
16 | set(CMAKE_CXX_EXTENSIONS OFF)
17 |
18 | set(CMAKE_VERBOSE_MAKEFILE ON)
19 |
20 | add_compile_options(
21 | -Wall -Wextra -msse3 -fopenmp
22 | $<$:-Ofast>
23 | $<$:-O0>
24 | $<$:-ggdb3>
25 | )
26 |
27 | add_compile_definitions(
28 | $<$:NDEBUG>
29 | )
30 |
31 | include_directories(${CSV_LIB_PATH})
32 |
33 | add_executable(csv_sample "csv.cc")
34 | target_link_libraries (csv_sample Eigen3::Eigen)
35 |
--------------------------------------------------------------------------------
/Chapter09/dlib/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.22)
2 | project(dlib-ensemble)
3 |
4 | find_package(dlib 19.24 REQUIRED)
5 |
6 | set(PLOTCPP_PATH "" CACHE PATH "path to poltcpp install dir")
7 |
8 | if (NOT PLOTCPP_PATH)
9 | message(FATAL_ERROR "Missigng plotcpp include path, please specify PLOTCPP_PATH")
10 | else()
11 | message("plotcpp path is ${PLOTCPP_PATH}")
12 | endif()
13 |
14 | set(CMAKE_CXX_STANDARD_REQUIRED ON)
15 | set(CMAKE_CXX_STANDARD 20)
16 | set(CMAKE_CXX_EXTENSIONS OFF)
17 |
18 | set(CMAKE_VERBOSE_MAKEFILE ON)
19 |
20 | add_compile_options(
21 | -Wall -Wextra -msse3 -fopenmp
22 | $<$:-Ofast>
23 | $<$:-O0>
24 | $<$:-ggdb3>
25 | )
26 |
27 | add_compile_definitions(
28 | $<$:NDEBUG>
29 | )
30 |
31 | include_directories(${PLOTCPP_PATH})
32 |
33 | add_executable(dlib-ensemble "dlib_ensemble.cc")
34 | target_link_libraries(dlib-ensemble dlib::dlib)
35 |
--------------------------------------------------------------------------------
/Chapter03/flashlight/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.10)
2 | project(grid-flashlight)
3 |
4 | find_package(flashlight 0.4.0 REQUIRED)
5 |
6 | set(PLOTCPP_PATH "" CACHE PATH "path to poltcpp install dir")
7 |
8 | if (NOT PLOTCPP_PATH)
9 | message(FATAL_ERROR "Missigng plotcpp include path, please specify PLOTCPP_PATH")
10 | else()
11 | message("plotcpp path is ${PLOTCPP_PATH}")
12 | endif()
13 |
14 | set(CMAKE_CXX_STANDARD_REQUIRED ON)
15 | set(CMAKE_CXX_STANDARD 20)
16 | set(CMAKE_CXX_EXTENSIONS OFF)
17 |
18 | set(CMAKE_VERBOSE_MAKEFILE ON)
19 |
20 | add_compile_options(
21 | -Wall -Wextra -msse3 -fopenmp
22 | $<$:-Ofast>
23 | $<$:-O0>
24 | $<$:-ggdb3>
25 | )
26 |
27 | add_compile_definitions(
28 | $<$:NDEBUG>
29 | )
30 |
31 | include_directories(${PLOTCPP_PATH})
32 |
33 | add_executable(grid_fl grid_fl.cc)
34 | target_link_libraries(grid_fl flashlight::flashlight)
35 |
--------------------------------------------------------------------------------
/Chapter02/csv/flashlight/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.0)
2 | project(flashlight-csv-sample)
3 |
4 | set(CSV_LIB_PATH "" CACHE PATH "Path to csv library include dir")
5 |
6 | if (NOT CSV_LIB_PATH)
7 | message(FATAL_ERROR "Missigng CSV lib install path, please specify CSV_LIB_PATH")
8 | else()
9 | message("CSV lib path is ${CSV_LIB_PATH}")
10 | endif()
11 |
12 | find_package(flashlight 0.4.0 REQUIRED)
13 |
14 | set(CMAKE_CXX_STANDARD_REQUIRED ON)
15 | set(CMAKE_CXX_STANDARD 20)
16 | set(CMAKE_CXX_EXTENSIONS OFF)
17 |
18 | set(CMAKE_VERBOSE_MAKEFILE ON)
19 |
20 | add_compile_options(
21 | -Wall -Wextra -msse3 -fopenmp
22 | $<$:-Ofast>
23 | $<$:-O0>
24 | $<$:-ggdb3>
25 | )
26 |
27 | add_compile_definitions(
28 | $<$:NDEBUG>
29 | )
30 |
31 | include_directories(${CSV_LIB_PATH})
32 |
33 | add_executable(csv_fl csv_fl.cc)
34 | target_link_libraries(csv_fl flashlight::flashlight)
35 |
--------------------------------------------------------------------------------
/Chapter08/mlpack/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.10)
2 | project(mlpack-recommender)
3 |
4 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
5 | find_package(mlpack 4.0.1 REQUIRED)
6 |
7 | find_package(Boost REQUIRED serialization)
8 |
9 | set(CMAKE_CXX_STANDARD_REQUIRED ON)
10 | set(CMAKE_CXX_STANDARD 20)
11 | set(CMAKE_CXX_EXTENSIONS OFF)
12 |
13 | add_compile_options(
14 | -Wall -Wextra -msse3 -fopenmp
15 | $<$:-Ofast>
16 | $<$:-O0>
17 | $<$:-ggdb3>
18 | )
19 |
20 | add_link_options(-fopenmp)
21 |
22 | add_compile_definitions(
23 | $<$:NDEBUG>
24 | )
25 |
26 | include_directories(${MLPACK_INCLUDE_DIR})
27 |
28 | add_executable(mlpack-recommender "mlpack_recommender.cc")
29 | target_link_directories(mlpack-recommender PRIVATE ${CMAKE_PREFIX_PATH}/lib)
30 | target_link_libraries(mlpack-recommender ${MLPACK_LIBRARIES} ${Boost_LIBRARIES} armadillo)
31 |
--------------------------------------------------------------------------------
/Chapter11/pytorch/imdbdataset.cc:
--------------------------------------------------------------------------------
1 | #include "imdbdataset.h"
2 | #include
3 | #include
4 |
5 | ImdbDataset::ImdbDataset(const std::string& dataset_path,
6 | std::shared_ptr tokenizer)
7 | : reader_(dataset_path), tokenizer_(std::move(tokenizer)) {}
8 |
9 | ImdbExample ImdbDataset::get(size_t index) {
10 | torch::Tensor target;
11 | const std::string* review{nullptr};
12 | if (index < reader_.get_pos_size()) {
13 | review = &reader_.get_pos(index);
14 | target = torch::tensor(1, torch::dtype(torch::kLong));
15 | } else {
16 | review = &reader_.get_neg(index - reader_.get_pos_size());
17 | target = torch::tensor(0, torch::dtype(torch::kLong));
18 | }
19 | // encode text
20 | auto tokenizer_out = tokenizer_->tokenize(*review);
21 |
22 | return {tokenizer_out, target.squeeze()};
23 | }
24 |
25 | torch::optional ImdbDataset::size() const {
26 | return reader_.get_pos_size() + reader_.get_neg_size();
27 | }
28 |
--------------------------------------------------------------------------------
/Chapter10/pytorch/mnistdataset.h:
--------------------------------------------------------------------------------
1 | #ifndef MNISTDATASET_H
2 | #define MNISTDATASET_H
3 |
4 | #include
5 | #include
6 |
7 | #include
8 |
9 | class MNISTDataset : public torch::data::Dataset {
10 | public:
11 | MNISTDataset(const std::string& images_file_name,
12 | const std::string& labels_file_name,
13 | torch::DeviceType device);
14 |
15 | // test only method
16 | void ShowItem(size_t index) const;
17 |
18 | // torch::data::Dataset implementation
19 | torch::data::Example<> get(size_t index) override;
20 | torch::optional size() const override;
21 |
22 | private:
23 | void ReadLabels(const std::string& labels_file_name);
24 | void ReadImages(const std::string& images_file_name);
25 |
26 | uint32_t rows_ = 0;
27 | uint32_t columns_ = 0;
28 | std::vector labels_;
29 | std::vector images_;
30 | torch::DeviceType device_;
31 | };
32 |
33 | #endif // MNISTDATASET_H
34 |
--------------------------------------------------------------------------------
/Chapter11/pytorch/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.22)
2 | project(sentiment-pytorch)
3 |
4 | find_package(Torch REQUIRED)
5 | find_package(OpenCV REQUIRED)
6 |
7 | set(CMAKE_VERBOSE_MAKEFILE ON)
8 | set(CMAKE_CXX_STANDARD_REQUIRED ON)
9 | set(CMAKE_CXX_STANDARD 20)
10 | set(CMAKE_CXX_EXTENSIONS OFF)
11 |
12 |
13 | include_directories(${TORCH_INCLUDE_DIRS})
14 |
15 | add_compile_options(
16 | -Wall -Wextra -msse3 -fopenmp
17 | $<$:-Ofast>
18 | $<$:-O0>
19 | $<$:-ggdb3>
20 | )
21 |
22 | set(SOURCE_FILES main.cpp
23 | tokenizer.h
24 | tokenizer.cc
25 | imdbdataset.h
26 | imdbdataset.cc
27 | imdbreader.cc
28 | imdbreader.h
29 | model.h
30 | model.cpp)
31 |
32 | add_executable("${CMAKE_PROJECT_NAME}" ${SOURCE_FILES})
33 | target_link_libraries("${CMAKE_PROJECT_NAME}" ${TORCH_LIBRARIES} ${OpenCV_LIBS})
34 |
35 |
--------------------------------------------------------------------------------
/Chapter12/mlpack/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.0)
2 | project(mlpack-save)
3 |
4 | include(FindPackageHandleStandardArgs)
5 |
6 | find_package(OpenMP REQUIRED)
7 |
8 | find_path(MLPACK_INCLUDE_DIR
9 | NAMES mlpack/core.hpp mlpack/prereqs.hpp
10 | )
11 |
12 | find_package_handle_standard_args(mlpack
13 | REQUIRED_VARS MLPACK_INCLUDE_DIR
14 | )
15 |
16 | set(CMAKE_CXX_STANDARD_REQUIRED ON)
17 | set(CMAKE_CXX_STANDARD 20)
18 | set(CMAKE_CXX_EXTENSIONS OFF)
19 |
20 | set(CMAKE_VERBOSE_MAKEFILE ON)
21 |
22 | add_compile_options(
23 | -Wall -Wextra -msse3 -fopenmp
24 | $<$:-Ofast>
25 | $<$:-O0>
26 | $<$:-ggdb3>
27 | )
28 |
29 | add_compile_definitions(
30 | $<$:NDEBUG>
31 | ARMA_DONT_USE_WRAPPER
32 | )
33 |
34 | include_directories(${MLPACK_INCLUDE_DIR})
35 |
36 | set(SOURCES
37 | mlpack-save.cc
38 | )
39 |
40 | add_executable(mlpack-save ${SOURCES})
41 | target_link_libraries(mlpack-save OpenMP::OpenMP_CXX blas lapack)
42 |
--------------------------------------------------------------------------------
/Chapter10/mlpack/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.0)
2 | project(mlp-mlpack)
3 |
4 | include(FindPackageHandleStandardArgs)
5 |
6 | find_package(OpenMP REQUIRED)
7 |
8 | find_path(MLPACK_INCLUDE_DIR
9 | NAMES mlpack/core.hpp mlpack/prereqs.hpp
10 | )
11 |
12 | find_package_handle_standard_args(mlpack
13 | REQUIRED_VARS MLPACK_INCLUDE_DIR
14 | )
15 |
16 | set(CMAKE_CXX_STANDARD_REQUIRED ON)
17 | set(CMAKE_CXX_STANDARD 20)
18 | set(CMAKE_CXX_EXTENSIONS OFF)
19 |
20 | set(CMAKE_VERBOSE_MAKEFILE ON)
21 |
22 | add_compile_options(
23 | -Wall -Wextra -msse3 -fopenmp
24 | $<$:-Ofast>
25 | $<$:-O0>
26 | $<$:-ggdb3>
27 | )
28 |
29 | add_compile_definitions(
30 | $<$:NDEBUG>
31 | ARMA_DONT_USE_WRAPPER
32 | )
33 |
34 | include_directories(${MLPACK_INCLUDE_DIR})
35 |
36 | set(SOURCES
37 | mlp_mlpack.cc
38 | ../data/data.h
39 | ../data/data.cc
40 | )
41 |
42 | add_executable(mlp-mlpack ${SOURCES})
43 | target_link_libraries(mlp-mlpack OpenMP::OpenMP_CXX blas lapack)
--------------------------------------------------------------------------------
/Chapter13/flashlight/mlflow.h:
--------------------------------------------------------------------------------
1 |
2 | #pragma once
3 |
4 | #include
5 |
6 | #include
7 |
8 | // The mlflow REST API use implementation https://mlflow.org/docs/latest/rest-api.html
9 | // 1. start a server with command: mlflow server --backend-store-uri file:///some_directory/mlruns
10 |
11 | class MLFlow {
12 | public:
13 | MLFlow();
14 | MLFlow(const std::string& host, size_t port);
15 |
16 | ~MLFlow() = default;
17 | MLFlow(const MLFlow&) = delete;
18 | MLFlow& operator=(const MLFlow&) = delete;
19 | MLFlow(MLFlow&&) = delete;
20 | MLFlow& operator=(MLFlow&&) = delete;
21 |
22 | void set_experiment(const std::string& name);
23 | void start_run();
24 | void end_run();
25 | void log_metric(const std::string& name, float value, size_t epoch);
26 | void log_param(const std::string& name, const std::string& value);
27 |
28 | template
29 | void log_param(const std::string& name, T value) {
30 | log_param(name, std::to_string(value));
31 | }
32 |
33 | private:
34 | httplib::Client http_client_;
35 | std::string experiment_id_;
36 | std::string run_id_;
37 | };
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2023 Packt
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 |
--------------------------------------------------------------------------------
/Chapter03/mlpack/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.10)
2 | project(mlpack-sample)
3 |
4 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
5 | find_package(mlpack 4.0.1 REQUIRED)
6 |
7 | set(PLOTCPP_PATH "" CACHE PATH "path to poltcpp install dir")
8 |
9 | if (NOT PLOTCPP_PATH)
10 | message(FATAL_ERROR "Missigng plotcpp include path, please specify PLOTCPP_PATH")
11 | else()
12 | message("plotcpp path is ${PLOTCPP_PATH}")
13 | endif()
14 |
15 |
16 | set(CMAKE_CXX_STANDARD_REQUIRED ON)
17 | set(CMAKE_CXX_STANDARD 20)
18 | set(CMAKE_CXX_EXTENSIONS OFF)
19 |
20 | add_compile_options(
21 | -Wall -Wextra -msse3 -fopenmp
22 | $<$:-Ofast>
23 | $<$:-O0>
24 | $<$:-ggdb3>
25 | )
26 |
27 | add_link_options(-fopenmp)
28 |
29 | add_compile_definitions(
30 | $<$:NDEBUG>
31 | )
32 |
33 | include_directories(${PLOTCPP_PATH})
34 | include_directories(${MLPACK_INCLUDE_DIR})
35 |
36 | add_executable(grid-mlpack "grid-mlpack.cc")
37 | target_link_directories(grid-mlpack PRIVATE ${CMAKE_PREFIX_PATH}/lib)
38 | target_link_libraries(grid-mlpack ${MLPACK_LIBRARIES} armadillo)
39 |
--------------------------------------------------------------------------------
/Chapter04/mlpack/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.10)
2 | project(mlpack-cluster)
3 |
4 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
5 | find_package(mlpack 4.0.1 REQUIRED)
6 |
7 | set(PLOTCPP_PATH "" CACHE PATH "path to poltcpp install dir")
8 |
9 | if (NOT PLOTCPP_PATH)
10 | message(FATAL_ERROR "Missigng plotcpp include path, please specify PLOTCPP_PATH")
11 | else()
12 | message("plotcpp path is ${PLOTCPP_PATH}")
13 | endif()
14 |
15 |
16 | set(CMAKE_CXX_STANDARD_REQUIRED ON)
17 | set(CMAKE_CXX_STANDARD 20)
18 | set(CMAKE_CXX_EXTENSIONS OFF)
19 |
20 | add_compile_options(
21 | -Wall -Wextra -msse3 -fopenmp
22 | $<$:-Ofast>
23 | $<$:-O0>
24 | $<$:-ggdb3>
25 | )
26 |
27 | add_link_options(-fopenmp)
28 |
29 | add_compile_definitions(
30 | $<$:NDEBUG>
31 | )
32 |
33 | include_directories(${PLOTCPP_PATH})
34 | include_directories(${MLPACK_INCLUDE_DIR})
35 |
36 | add_executable(mlpack-cluster "mlpack-cluster.cc")
37 | target_link_directories(mlpack-cluster PRIVATE ${CMAKE_PREFIX_PATH}/lib)
38 | target_link_libraries(mlpack-cluster ${MLPACK_LIBRARIES} armadillo)
39 |
--------------------------------------------------------------------------------
/Chapter05/mlpack/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.10)
2 | project(mlpack-anomaly)
3 |
4 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
5 | find_package(mlpack 4.0.1 REQUIRED)
6 |
7 | set(PLOTCPP_PATH "" CACHE PATH "path to poltcpp install dir")
8 |
9 | if (NOT PLOTCPP_PATH)
10 | message(FATAL_ERROR "Missigng plotcpp include path, please specify PLOTCPP_PATH")
11 | else()
12 | message("plotcpp path is ${PLOTCPP_PATH}")
13 | endif()
14 |
15 |
16 | set(CMAKE_CXX_STANDARD_REQUIRED ON)
17 | set(CMAKE_CXX_STANDARD 20)
18 | set(CMAKE_CXX_EXTENSIONS OFF)
19 |
20 | add_compile_options(
21 | -Wall -Wextra -msse3 -fopenmp
22 | $<$:-Ofast>
23 | $<$:-O0>
24 | $<$:-ggdb3>
25 | )
26 |
27 | add_link_options(-fopenmp)
28 |
29 | add_compile_definitions(
30 | $<$:NDEBUG>
31 | )
32 |
33 | include_directories(${PLOTCPP_PATH})
34 | include_directories(${MLPACK_INCLUDE_DIR})
35 |
36 | add_executable(mlpack-anomaly "mlpack-anomaly.cc")
37 | target_link_directories(mlpack-anomaly PRIVATE ${CMAKE_PREFIX_PATH}/lib)
38 | target_link_libraries(mlpack-anomaly ${MLPACK_LIBRARIES} armadillo)
39 |
--------------------------------------------------------------------------------
/Chapter07/mlpack/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.10)
2 | project(mlpack-classify)
3 |
4 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
5 | find_package(mlpack 4.0.1 REQUIRED)
6 |
7 | set(PLOTCPP_PATH "" CACHE PATH "path to poltcpp install dir")
8 |
9 | if (NOT PLOTCPP_PATH)
10 | message(FATAL_ERROR "Missigng plotcpp include path, please specify PLOTCPP_PATH")
11 | else()
12 | message("plotcpp path is ${PLOTCPP_PATH}")
13 | endif()
14 |
15 |
16 | set(CMAKE_CXX_STANDARD_REQUIRED ON)
17 | set(CMAKE_CXX_STANDARD 20)
18 | set(CMAKE_CXX_EXTENSIONS OFF)
19 |
20 | add_compile_options(
21 | -Wall -Wextra -msse3 -fopenmp
22 | $<$:-Ofast>
23 | $<$:-O0>
24 | $<$:-ggdb3>
25 | )
26 |
27 | add_link_options(-fopenmp)
28 |
29 | add_compile_definitions(
30 | $<$:NDEBUG>
31 | )
32 |
33 | include_directories(${PLOTCPP_PATH})
34 | include_directories(${MLPACK_INCLUDE_DIR})
35 |
36 | add_executable(mlpack-classify "mlpack-classify.cc")
37 | target_link_directories(mlpack-classify PRIVATE ${CMAKE_PREFIX_PATH}/lib)
38 | target_link_libraries(mlpack-classify ${MLPACK_LIBRARIES} armadillo)
39 |
--------------------------------------------------------------------------------
/Chapter14/android_detection/gradle/libs.versions.toml:
--------------------------------------------------------------------------------
1 | [versions]
2 | agp = "8.5.1"
3 | kotlin = "1.9.0"
4 | coreKtx = "1.13.1"
5 | junit = "4.13.2"
6 | junitVersion = "1.2.1"
7 | espressoCore = "3.6.1"
8 | appcompat = "1.7.0"
9 | material = "1.12.0"
10 | constraintlayout = "2.1.4"
11 |
12 | [libraries]
13 | androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
14 | junit = { group = "junit", name = "junit", version.ref = "junit" }
15 | androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" }
16 | androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" }
17 | androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" }
18 | material = { group = "com.google.android.material", name = "material", version.ref = "material" }
19 | androidx-constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" }
20 |
21 | [plugins]
22 | android-application = { id = "com.android.application", version.ref = "agp" }
23 | jetbrains-kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
24 |
25 |
--------------------------------------------------------------------------------
/Chapter11/pytorch/model.cpp:
--------------------------------------------------------------------------------
1 | #include "model.h"
2 |
3 | ModelImpl::ModelImpl(const std::string& bert_model_path)
4 | : dropout_(register_module("dropout", torch::nn::Dropout(torch::nn::DropoutOptions().p(0.2)))),
5 | fc1_(register_module("fc1", torch::nn::Linear(torch::nn::LinearOptions(768, 512)))),
6 | fc2_(register_module("fc2", torch::nn::Linear(torch::nn::LinearOptions(512, 2)))) {
7 | bert_ = torch::jit::load(bert_model_path);
8 | }
9 |
10 | torch::Tensor ModelImpl::forward(at::Tensor input_ids, at::Tensor attention_masks) {
11 | std::vector inputs = {input_ids, attention_masks};
12 | auto bert_output = bert_.forward(inputs);
13 | // Pooled output is the embedding of the [CLS] token (from Sequence output),
14 | // further processed by a Linear layer and a Tanh activation function.
15 | // The Linear layer weights are trained from the next sentence prediction
16 | // (classification) objective during pretraining.
17 | auto pooler_output = bert_output.toTuple()->elements()[1].toTensor();
18 | auto x = fc1_(pooler_output);
19 | x = torch::nn::functional::relu(x);
20 | x = dropout_(x);
21 | x = fc2_(x);
22 | x = torch::softmax(x, /*dim=*/1);
23 | return x;
24 | }
25 |
--------------------------------------------------------------------------------
/Chapter03/mlpack/cmake/Findmlpack.cmake:
--------------------------------------------------------------------------------
1 | #.rst:
2 | # Findmlpack
3 | # -------------
4 | #
5 | # Find mlpack
6 | #
7 | # Find the mlpack C++ library
8 | #
9 | # Using mlpack::
10 | #
11 | # find_package(mlpack REQUIRED)
12 | # include_directories(${MLPACK_INCLUDE_DIRS})
13 | # add_executable(foo foo.cc)
14 | #
15 | # This module sets the following variables::
16 | #
17 | # mlpack_FOUND - set to true if the library is found
18 | # MLPACK_INCLUDE_DIRS - list of required include directories
19 | # MLPACK_VERSION_MAJOR - major version number
20 | # MLPACK_VERSION_MINOR - minor version number
21 | # MLPACK_VERSION_PATCH - patch version number
22 | # MLPACK_VERSION_STRING - version number as a string (ex: "1.0.4")
23 |
24 | include(FindPackageHandleStandardArgs)
25 |
26 | message(INFO "Looking mlpack in ${CMAKE_PREFIX_PATH}")
27 | find_path(MLPACK_INCLUDE_DIR
28 | NAMES mlpack/core.hpp mlpack/prereqs.hpp
29 | PATHS "${CMAKE_PREFIX_PATH}/include/"
30 | )
31 |
32 | find_package_handle_standard_args(mlpack
33 | REQUIRED_VARS MLPACK_INCLUDE_DIR
34 | )
35 |
36 | if(mlpack_FOUND)
37 | set(MLPACK_INCLUDE_DIRS ${MLPACK_INCLUDE_DIR})
38 | endif()
39 |
40 | # Hide internal variables
41 | mark_as_advanced(MLPACK_INCLUDE_DIR)
--------------------------------------------------------------------------------
/Chapter04/mlpack/cmake/Findmlpack.cmake:
--------------------------------------------------------------------------------
1 | #.rst:
2 | # Findmlpack
3 | # -------------
4 | #
5 | # Find mlpack
6 | #
7 | # Find the mlpack C++ library
8 | #
9 | # Using mlpack::
10 | #
11 | # find_package(mlpack REQUIRED)
12 | # include_directories(${MLPACK_INCLUDE_DIRS})
13 | # add_executable(foo foo.cc)
14 | #
15 | # This module sets the following variables::
16 | #
17 | # mlpack_FOUND - set to true if the library is found
18 | # MLPACK_INCLUDE_DIRS - list of required include directories
19 | # MLPACK_VERSION_MAJOR - major version number
20 | # MLPACK_VERSION_MINOR - minor version number
21 | # MLPACK_VERSION_PATCH - patch version number
22 | # MLPACK_VERSION_STRING - version number as a string (ex: "1.0.4")
23 |
24 | include(FindPackageHandleStandardArgs)
25 |
26 | message(INFO "Looking mlpack in ${CMAKE_PREFIX_PATH}")
27 | find_path(MLPACK_INCLUDE_DIR
28 | NAMES mlpack/core.hpp mlpack/prereqs.hpp
29 | PATHS "${CMAKE_PREFIX_PATH}/include/"
30 | )
31 |
32 | find_package_handle_standard_args(mlpack
33 | REQUIRED_VARS MLPACK_INCLUDE_DIR
34 | )
35 |
36 | if(mlpack_FOUND)
37 | set(MLPACK_INCLUDE_DIRS ${MLPACK_INCLUDE_DIR})
38 | endif()
39 |
40 | # Hide internal variables
41 | mark_as_advanced(MLPACK_INCLUDE_DIR)
--------------------------------------------------------------------------------
/Chapter05/mlpack/cmake/Findmlpack.cmake:
--------------------------------------------------------------------------------
1 | #.rst:
2 | # Findmlpack
3 | # -------------
4 | #
5 | # Find mlpack
6 | #
7 | # Find the mlpack C++ library
8 | #
9 | # Using mlpack::
10 | #
11 | # find_package(mlpack REQUIRED)
12 | # include_directories(${MLPACK_INCLUDE_DIRS})
13 | # add_executable(foo foo.cc)
14 | #
15 | # This module sets the following variables::
16 | #
17 | # mlpack_FOUND - set to true if the library is found
18 | # MLPACK_INCLUDE_DIRS - list of required include directories
19 | # MLPACK_VERSION_MAJOR - major version number
20 | # MLPACK_VERSION_MINOR - minor version number
21 | # MLPACK_VERSION_PATCH - patch version number
22 | # MLPACK_VERSION_STRING - version number as a string (ex: "1.0.4")
23 |
24 | include(FindPackageHandleStandardArgs)
25 |
26 | message(INFO "Looking mlpack in ${CMAKE_PREFIX_PATH}")
27 | find_path(MLPACK_INCLUDE_DIR
28 | NAMES mlpack/core.hpp mlpack/prereqs.hpp
29 | PATHS "${CMAKE_PREFIX_PATH}/include/"
30 | )
31 |
32 | find_package_handle_standard_args(mlpack
33 | REQUIRED_VARS MLPACK_INCLUDE_DIR
34 | )
35 |
36 | if(mlpack_FOUND)
37 | set(MLPACK_INCLUDE_DIRS ${MLPACK_INCLUDE_DIR})
38 | endif()
39 |
40 | # Hide internal variables
41 | mark_as_advanced(MLPACK_INCLUDE_DIR)
--------------------------------------------------------------------------------
/Chapter07/mlpack/cmake/Findmlpack.cmake:
--------------------------------------------------------------------------------
1 | #.rst:
2 | # Findmlpack
3 | # -------------
4 | #
5 | # Find mlpack
6 | #
7 | # Find the mlpack C++ library
8 | #
9 | # Using mlpack::
10 | #
11 | # find_package(mlpack REQUIRED)
12 | # include_directories(${MLPACK_INCLUDE_DIRS})
13 | # add_executable(foo foo.cc)
14 | #
15 | # This module sets the following variables::
16 | #
17 | # mlpack_FOUND - set to true if the library is found
18 | # MLPACK_INCLUDE_DIRS - list of required include directories
19 | # MLPACK_VERSION_MAJOR - major version number
20 | # MLPACK_VERSION_MINOR - minor version number
21 | # MLPACK_VERSION_PATCH - patch version number
22 | # MLPACK_VERSION_STRING - version number as a string (ex: "1.0.4")
23 |
24 | include(FindPackageHandleStandardArgs)
25 |
26 | message(INFO "Looking mlpack in ${CMAKE_PREFIX_PATH}")
27 | find_path(MLPACK_INCLUDE_DIR
28 | NAMES mlpack/core.hpp mlpack/prereqs.hpp
29 | PATHS "${CMAKE_PREFIX_PATH}/include/"
30 | )
31 |
32 | find_package_handle_standard_args(mlpack
33 | REQUIRED_VARS MLPACK_INCLUDE_DIR
34 | )
35 |
36 | if(mlpack_FOUND)
37 | set(MLPACK_INCLUDE_DIRS ${MLPACK_INCLUDE_DIR})
38 | endif()
39 |
40 | # Hide internal variables
41 | mark_as_advanced(MLPACK_INCLUDE_DIR)
--------------------------------------------------------------------------------
/Chapter08/mlpack/cmake/Findmlpack.cmake:
--------------------------------------------------------------------------------
1 | #.rst:
2 | # Findmlpack
3 | # -------------
4 | #
5 | # Find mlpack
6 | #
7 | # Find the mlpack C++ library
8 | #
9 | # Using mlpack::
10 | #
11 | # find_package(mlpack REQUIRED)
12 | # include_directories(${MLPACK_INCLUDE_DIRS})
13 | # add_executable(foo foo.cc)
14 | #
15 | # This module sets the following variables::
16 | #
17 | # mlpack_FOUND - set to true if the library is found
18 | # MLPACK_INCLUDE_DIRS - list of required include directories
19 | # MLPACK_VERSION_MAJOR - major version number
20 | # MLPACK_VERSION_MINOR - minor version number
21 | # MLPACK_VERSION_PATCH - patch version number
22 | # MLPACK_VERSION_STRING - version number as a string (ex: "1.0.4")
23 |
24 | include(FindPackageHandleStandardArgs)
25 |
26 | message(INFO "Looking mlpack in ${CMAKE_PREFIX_PATH}")
27 | find_path(MLPACK_INCLUDE_DIR
28 | NAMES mlpack/core.hpp mlpack/prereqs.hpp
29 | PATHS "${CMAKE_PREFIX_PATH}/include/"
30 | )
31 |
32 | find_package_handle_standard_args(mlpack
33 | REQUIRED_VARS MLPACK_INCLUDE_DIR
34 | )
35 |
36 | if(mlpack_FOUND)
37 | set(MLPACK_INCLUDE_DIRS ${MLPACK_INCLUDE_DIR})
38 | endif()
39 |
40 | # Hide internal variables
41 | mark_as_advanced(MLPACK_INCLUDE_DIR)
--------------------------------------------------------------------------------
/Chapter09/mlpack/cmake/Findmlpack.cmake:
--------------------------------------------------------------------------------
1 | #.rst:
2 | # Findmlpack
3 | # -------------
4 | #
5 | # Find mlpack
6 | #
7 | # Find the mlpack C++ library
8 | #
9 | # Using mlpack::
10 | #
11 | # find_package(mlpack REQUIRED)
12 | # include_directories(${MLPACK_INCLUDE_DIRS})
13 | # add_executable(foo foo.cc)
14 | #
15 | # This module sets the following variables::
16 | #
17 | # mlpack_FOUND - set to true if the library is found
18 | # MLPACK_INCLUDE_DIRS - list of required include directories
19 | # MLPACK_VERSION_MAJOR - major version number
20 | # MLPACK_VERSION_MINOR - minor version number
21 | # MLPACK_VERSION_PATCH - patch version number
22 | # MLPACK_VERSION_STRING - version number as a string (ex: "1.0.4")
23 |
24 | include(FindPackageHandleStandardArgs)
25 |
26 | message(INFO "Looking mlpack in ${CMAKE_PREFIX_PATH}")
27 | find_path(MLPACK_INCLUDE_DIR
28 | NAMES mlpack/core.hpp mlpack/prereqs.hpp
29 | PATHS "${CMAKE_PREFIX_PATH}/include/"
30 | )
31 |
32 | find_package_handle_standard_args(mlpack
33 | REQUIRED_VARS MLPACK_INCLUDE_DIR
34 | )
35 |
36 | if(mlpack_FOUND)
37 | set(MLPACK_INCLUDE_DIRS ${MLPACK_INCLUDE_DIR})
38 | endif()
39 |
40 | # Hide internal variables
41 | mark_as_advanced(MLPACK_INCLUDE_DIR)
--------------------------------------------------------------------------------
/Chapter10/mlpack/cmake/Findmlpack.cmake:
--------------------------------------------------------------------------------
1 | #.rst:
2 | # Findmlpack
3 | # -------------
4 | #
5 | # Find mlpack
6 | #
7 | # Find the mlpack C++ library
8 | #
9 | # Using mlpack::
10 | #
11 | # find_package(mlpack REQUIRED)
12 | # include_directories(${MLPACK_INCLUDE_DIRS})
13 | # add_executable(foo foo.cc)
14 | #
15 | # This module sets the following variables::
16 | #
17 | # mlpack_FOUND - set to true if the library is found
18 | # MLPACK_INCLUDE_DIRS - list of required include directories
19 | # MLPACK_VERSION_MAJOR - major version number
20 | # MLPACK_VERSION_MINOR - minor version number
21 | # MLPACK_VERSION_PATCH - patch version number
22 | # MLPACK_VERSION_STRING - version number as a string (ex: "1.0.4")
23 |
24 | include(FindPackageHandleStandardArgs)
25 |
26 | message(INFO "Looking mlpack in ${CMAKE_PREFIX_PATH}")
27 | find_path(MLPACK_INCLUDE_DIR
28 | NAMES mlpack/core.hpp mlpack/prereqs.hpp
29 | PATHS "${CMAKE_PREFIX_PATH}/include/"
30 | )
31 |
32 | find_package_handle_standard_args(mlpack
33 | REQUIRED_VARS MLPACK_INCLUDE_DIR
34 | )
35 |
36 | if(mlpack_FOUND)
37 | set(MLPACK_INCLUDE_DIRS ${MLPACK_INCLUDE_DIR})
38 | endif()
39 |
40 | # Hide internal variables
41 | mark_as_advanced(MLPACK_INCLUDE_DIR)
--------------------------------------------------------------------------------
/Chapter12/mlpack/cmake/Findmlpack.cmake:
--------------------------------------------------------------------------------
1 | #.rst:
2 | # Findmlpack
3 | # -------------
4 | #
5 | # Find mlpack
6 | #
7 | # Find the mlpack C++ library
8 | #
9 | # Using mlpack::
10 | #
11 | # find_package(mlpack REQUIRED)
12 | # include_directories(${MLPACK_INCLUDE_DIRS})
13 | # add_executable(foo foo.cc)
14 | #
15 | # This module sets the following variables::
16 | #
17 | # mlpack_FOUND - set to true if the library is found
18 | # MLPACK_INCLUDE_DIRS - list of required include directories
19 | # MLPACK_VERSION_MAJOR - major version number
20 | # MLPACK_VERSION_MINOR - minor version number
21 | # MLPACK_VERSION_PATCH - patch version number
22 | # MLPACK_VERSION_STRING - version number as a string (ex: "1.0.4")
23 |
24 | include(FindPackageHandleStandardArgs)
25 |
26 | message(INFO "Looking mlpack in ${CMAKE_PREFIX_PATH}")
27 | find_path(MLPACK_INCLUDE_DIR
28 | NAMES mlpack/core.hpp mlpack/prereqs.hpp
29 | PATHS "${CMAKE_PREFIX_PATH}/include/"
30 | )
31 |
32 | find_package_handle_standard_args(mlpack
33 | REQUIRED_VARS MLPACK_INCLUDE_DIR
34 | )
35 |
36 | if(mlpack_FOUND)
37 | set(MLPACK_INCLUDE_DIRS ${MLPACK_INCLUDE_DIR})
38 | endif()
39 |
40 | # Hide internal variables
41 | mark_as_advanced(MLPACK_INCLUDE_DIR)
--------------------------------------------------------------------------------
/Chapter14/android_detection/app/src/main/assets/classes.txt:
--------------------------------------------------------------------------------
1 | 0:person
2 | 1:bicycle
3 | 2:car
4 | 3:motorcycle
5 | 4:airplane
6 | 5:bus
7 | 6:train
8 | 7:truck
9 | 8:boat
10 | 9:traffic-light
11 | 10:fire-hydrant
12 | 11:stop-sign
13 | 12:parking-meter
14 | 13:bench
15 | 14:bird
16 | 15:cat
17 | 16:dog
18 | 17:horse
19 | 18:sheep
20 | 19:cow
21 | 20:elephant
22 | 21:bear
23 | 22:zebra
24 | 23:giraffe
25 | 24:backpack
26 | 25:umbrella
27 | 26:handbag
28 | 27:tie
29 | 28:suitcase
30 | 29:frisbee
31 | 30:skis
32 | 31:snowboard
33 | 32:sports-ball
34 | 33:kite
35 | 34:baseball-bat
36 | 35:baseball-glove
37 | 36:skateboard
38 | 37:surfboard
39 | 38:tennis-racket
40 | 39:bottle
41 | 40:wine-glass
42 | 41:cup
43 | 42:fork
44 | 43:knife
45 | 44:spoon
46 | 45:bowl
47 | 46:banana
48 | 47:apple
49 | 48:sandwich
50 | 49:orange
51 | 50:broccoli
52 | 51:carrot
53 | 52:hot-dog
54 | 53:pizza
55 | 54:donut
56 | 55:cake
57 | 56:chair
58 | 57:couch
59 | 58:potted-plant
60 | 59:bed
61 | 60:dining-table
62 | 61:toilet
63 | 62:tv
64 | 63:laptop
65 | 64:mouse
66 | 65:remote
67 | 66:keyboard
68 | 67:cell-phone
69 | 68:microwave
70 | 69:oven
71 | 70:toaster
72 | 71:sink
73 | 72:refrigerator
74 | 73:book
75 | 74:clock
76 | 75:vase
77 | 76:scissors
78 | 77:teddy-bear
79 | 78:hair-drier
80 | 79:toothbrush
--------------------------------------------------------------------------------
/Chapter14/android_detection/app/src/main/cpp/yolo.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 | #include
6 | #include
7 | #include