原创 cpp map+multimap 的常用操作 -- 每天一個寫bug小技巧

文章目錄map最後一位元素multimap取鍵值爲某個值的所有pair map c++ map 相當於python 中的dict, 一個關鍵詞對應一個值(multimap可以對應多個值) map默認是排好序的,如果有需要用到排序的

原创 cpp vector 基本使用方法

1. 初始化 vector<T> T是類型,如int,string. 1.1 創造n行m列二維數組 vector<vector<int> > Matrix(n, vector<int>(m)); 2. 刪除 2.1 cle

原创 leetcode problem 538. Convert BST to Greater Tree

Description Given a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original BST

原创 latex 公式編輯方法

各種數學符號 期望E \mathbb{E} 公式 1. 對齊 \begin{align*} f(x) &= (x+a)(x+b) \\ &= x^2 + (a+b)x + ab \end{align*}

原创 cpp printf -- 每天一個寫bug小技巧

% type c char d int s string f float e float in exp p 指針

原创 Latex學習筆記 -- 每天一個寫 bug 小技巧

引用 一般的latex模板會提供以.bst 結尾的文件,可以理解爲bib style, 另外還有一個以.bib 結尾的文件, 比如現在我有兩個文件 style.bst 和 cite.bib 要完成引用只需在\end{docum

原创 python networkx 用法 -- 每天一個寫 bug 小技巧

創建圖 import networkx as nx G = nx.Graph() # 創建空圖 G = nx.karate_club_graph() # 創建karate圖,經典圖之一(還有很多其他的 可視化 import ne

原创 leetcode problem 62. Unique Paths [20190417]

Description A robot is located at the top-left corner of a m x n grid (marked ‘Start’ in the diagram below). The ro

原创 [tensorflow] tf.app.flags 使用

經常看到下面這樣的情況, 在一個b.py文件裏,有下面這樣的代碼 b.py: import tensorflow as tf flags = tf.app.flags FLAGS = flags.FLAGS print(FLA

原创 RuntimeError: expected device cpu but got device cuda:0 --每天一個寫 bug 小技巧

這是一個綜合 debug 方法: 不管是 expected cpu 還是 expected cuda, 本質原因都是類型不匹配。 一般是因爲: 等號左邊和右邊類型不一樣 運算符左右兩端類型不同 同一個函數內,傳入參數類型不同,比

原创 RL policy gradient 之 A2C, A3C,PPO小總結

A2C, A3C, PPO 都不是純 policy based 的 RL 方法,準確地說是 Actor-Critic 方法,即,同時用到了 value function 和 policy funtion. 這三種方法之間有什麼區別

原创 Missing number, treated as zero. to be read again Illegal unit of measure (pt inserted)

文章目錄環境錯誤方法可行方法 環境 macOS+vscode+xelatex編譯 錯誤方法 想在latex文檔裏插入並排的圖片,一開始找到的博客說這麼做: \begin{figure}[H] \centering

原创 Latex figure 引用顯示錯誤

在latex中插入圖片後,引用發現,不顯示標號或者是標號顯示錯誤, 我遇到的是:明明寫了引用: \ref{fig:1} \ref{fig:2} 是不一樣的,但是在 PDF 中,顯示的是相同的 數字, 都是 Figure 1。

原创 KL散度

1. 形式 一般而言,P代表數據x的真實分佈,Q代表理論分佈。 離散: KL(P∣∣Q)=∑P(x)log⁡P(x)Q(x) KL(P||Q) = \sum P(x) \log \frac{P(x)}{Q(x)} \\ KL(P∣

原创 cpp printf("%d", mp.size()) warning

mp.size() 的數據類型不是int,需要改成 %lu