原创 std::make_heap, std::pop_heap, std::push_heap, std::sort_heap

std::make_heap #include <iostream> #include <algorithm> #include <vector> int main() { std::vector<int> vec{ 10,2

原创 Doxyfile Template

# Doxyfile 1.8.18 # This file describes the settings to be used by the documentation system # doxygen (www.doxygen

原创 CompileTengine

cmake產生Makefile cd /path/to/Tengine mkdir build; cd build cmake -DCMAKE_TOOLCHAIN_FILE=../toolchains/x86_convert_to

原创 Be aware of template metaprogramming

TMP沒有真正的循環構件,循環效果由遞歸recursion完成。 TMP是函數式語言functional language,而遞歸對於這類語言是無法分割的。 TMP的遞歸不是正常的遞歸,因爲TMP循環並不涉及遞歸函數調用,而是涉及

原创 Understand the behavior of the new-handler

示例1: #include <new> class NewHandlerHolder { public: NewHandlerHolder(std::new_handler handler) /*: m_handler(

原创 Strategy-object Behavioral

古典的Strategy模式 #pragma once #include <functional> class GameCharacter; // forward declaration class HealthCalcFu

原创 pass-by-value有哪些問題?

問題1, 參數切割slicing #include <string> #include <iostream> class Window { public: Window() { std::cout <<

原创 小心RAII中的copying行爲

禁止複製 #include <iostream> #include <thread> #include <mutex> void print(int *arr, int dim); class Lock { public:

原创 constructor和destructor不可以調用virtual函數

/* constructor和destructor不可以調用virtual函數 constructor: 因爲構造derived類的對象的時候首先調用base類的constructor, 而b

原创 TensorFlow Errors

1. 應當傳值而不是傳Tensor a. 報錯示例1: TypeError: int() argument must be a string, a bytes-like object or a number, not 'Tenso

原创 numpy

1. numpy.fromfunction() 圖1 numpy.fromfunction() 2. np.iinfo(), np.finfo() 圖2 np.*info

原创 SVM

SVM 1. 基本概念 支持向量機(Support Vector Machine, SVM)的基本模型是在特徵空間上找到最佳的分離超平面使得訓練集上正負樣本間隔最大。SVM是用來解決二分類問題的有監督學習算法,在引入了核方法之後

原创 Adaboost

Adaboost Boosting(提升方法)是一族可以將弱分類器提升爲強分類器的方法。這族算法的工作原理是:先從初始訓練集訓練出一個基分類器,再根據基分類器的表現對訓練樣本權值進行調整,使得被基分類器分錯的樣本得到更多的關注,然

原创 API Design for C++之Pimpl設計模式

創建API的主要原因是隱藏所有的實現細節,以免將來修改API對已有客戶造成影響。任何內部實現細節(那些很可能變更的部分)必須對該API的客戶隱藏。主要有兩種技巧可以達到此目標:物理隱藏和邏輯隱藏。 物理隱藏:不讓用戶獲得私有源代

原创 樸素貝葉斯分類器

樸素貝葉斯分類器(Naive Bayes Classifier) 基本概念 貝葉斯分類器是一族分類算法的總稱,該族算法均以貝葉斯定理爲基礎,統稱爲貝葉斯分類器。貝葉斯分類器的分類原理是通過先驗概率利用貝葉斯公式計算出其後驗概率,選