原创 c++不同數據處理類型函數,使用宏統一命名

#include <iostream> #include <map> namespace teaflow { #define function_alias(A, B) \ template <typename... Arg> \

原创 PCA降維(公式推導)

PCA PCA線性投影降維的方法。當維度p高,樣本少。 p>> N , S=1NXXT S= \frac{1}{N}XX^T S=N1​XXT 因爲 xn是Rp×1x_n 是 R^{p \times 1}xn​是Rp×1 所以Ra

原创 MinHash 和LSH

Min Hash 實現 具體的原理參考:https://zhuanlan.zhihu.com/p/46164294 from scipy.spatial.distance import cosine from random imp

原创 python 擴展c extention

首先我們會使用PyMODINIT_FUNC 和PyMethodDef 進行創建c的擴展。 關於PyMethodDef可以的參數含義可以在官網查看 第一步 // 簡單的say hello 函數 static PyObject* sa

原创 在JIT編譯時期進行類型檢查

#include <iostream> #include <list> #include <vector> using std::list; #include <map> template <typename T> using

原创 c++ 實現對象迭代器

#include <iostream> #include <list> #include <vector> using std::list; template <typename T, typename To> struct

原创 c++ 編譯動態庫出現undefined symbol

如何debug 可以使用nm指令查看undifined simbol的編譯的位置: nm -D test.so 輸出: 000000000099a4dc B _ZN7teaflow9ns_uint64E 00000000002

原创 c++ syntax new (this) T(t) 不用額外分配內存,直接copy

T& T::operator=(const T&t) { ... new (this) T(t); ... } new (this) T(t) 也叫做“new placement operator”。在括號中

原创 BERT模型(學習筆記)

BERT: Bidirectional Encoder Representations from Transformers 主要工作: (1)預訓練: 使用預訓練的模型去提取詞或者句子的特徵 (2)問題: 語言模型使用左邊或者右邊

原创 GPT模型(學習筆記)

GPT模型 Gererate Pre-Training Model 本質上是無監督的學習,在transformer的基礎之上層數增加到12層。 在模型方面沒有很大的貢獻,證明了大模型、大數據集有效。 數據集: Books Corp

原创 pybind11

pybind11 github 地址:https://github.com/pybind/pybind11 cmake 編譯:

原创 python實現樸素的卷積操作

import numpy as np import os # 樸素的卷積 def conv_naive(x, w): N,H,W,C = x.shape Kh, Kw, _C, Kc = w.shape

原创 Attention (學習筆記)

Seq-Seq 模型的困難: p(y1,...yT)∣x1,...xT=∏t=1T′p(yt∣c,y1,...,yt−1)=∏t=1T′g(c,st−2,yt−1)p(y_1,...y_T)|x_1,...x_T=\prod _

原创 時間序列的反向傳播算法(BPTT)

時間序列的反向傳播算法 BPTT : Back-Propagation Through Time ∂L∂U=∑t∂Lt∂U\frac{\partial L}{\partial U} = \sum_t\frac{\partial

原创 循環神經網絡(學習筆記)

簡單的是語言的概率模型,根據前面的單詞推斷下一個單詞。 p(wordi∣word1,...,wordi−1)p(word_i|word_1,...,word_{i-1})p(wordi​∣word1​,...,wordi−1​)