jwcao's notes


  • 首页

  • 标签

  • 分类

  • 归档

Tips of Git

发表于 2018-02-27 | 分类于 工具 , Git

Tips of Git


  • delete submodule

1
2
$ git rm the_submodule
$ rm -rf .git/modules/the_submodule
  • ignore submodule

1
2
$ echo "sub_repo/" >> .gitignore
$ git clone https://user@bitbucket.org/user/repo.git sub_repo

基于hexo和git的博客搭建

发表于 2018-02-27 | 分类于 技术 , web

基于hexo和git的博客搭建


  • 安装依赖

    • node.js

    • git

    1
    $ npm install hexo-deployer-git --save
  • 建站

1
2
3
$ hexo init <folder>
$ cd <folder>
$ npm install
  • 配置

修改站点配置文件_config.yml

1
2
3
deploy:
type: git
repo: git@github.com:ahujwcao/ahujwcao.github.io.git
  • 命令与基本操作

    • new

    1
    $ hexo new [layout] <title>
    • generate

    1
    $ hexo g
    • server

    1
    $ hexo s
    • deploy

    1
    $ hexo d
  • 域名绑定

    申请域名,如阿里云,添加域名解析

node.js install

发表于 2018-02-27 | 分类于 工具

Install Node.js


  • using nvm
1
2
$ wget -qO- https://raw.github.com/creationix/nvm/master/install.sh | sh
$ nvm install stable

二叉树

发表于 2018-02-26 | 分类于 技术 , 数据结构

未完待续

Some Python Grammar

发表于 2018-02-26 | 分类于 技术 , Python

Some Basic Grammar


1.Built-In Types and Data Structures

2.Control Flow

  • if Statements

    1
    2
    3
    4
    5
    6
    if x < 0:
    print("x < 0")
    elif x == 0:
    print("x==0")
    else:
    print("x > 0")

  • for Statements

    1
    2
    3
    4
    5
    6
    >>> for w in words[:]:  # Loop over a slice copy of the entire list.
    ... if len(w) > 6:
    ... words.insert(0, w)
    ...
    >>> words
    ['defenestrate', 'cat', 'window', 'defenestrate']

  • range() Function

    1
    2
    3
    4
    5
    6
    7
    8
    >>> for i in range(3):
    ... print(i)
    ...
    0
    1
    2
    >>> list(range(5))
    [0, 1, 2, 3, 4]

  • break and continue Statements, and else Clauses on Loops The else Clauses is executed when the loop terminates through exhaustion of the list (with for) or when the condition becomes false (with while), but not when the loop is terminated by a break statement.

1
2
3
4
5
6
7
8
9
10
11
12
>>> for n in range(2, 5):
... for x in range(2, n):
... if n % x == 0:
... print(n, 'equals', x, '*', n//x)
... break
... else:
... # loop fell through without finding a factor
... print(n, 'is a prime number')
...
2 is a prime number
3 is a prime number
4 equals 2 * 2
  • Defining Functions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
>>> def fib(n):    # write Fibonacci series up to n
... """Print a Fibonacci series up to n."""
... a, b = 0, 1
... while a < n:
... print(a, end=' ')
... a, b = b, a+b
... print()
...
>>> # Now call the function we just defined:
... fib(2000)
0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597
#---------------------------------------------------------
# parameter passing
def foo(a, b):
"parameter passing in function"
print(">>>parameter passing")
print("addr(a) = {:#X}, addr(b) = {:#X}".format(id(a), id(b)))
a = 2
b.append(1)
print(">>>assignments")
print("addr(a) = {:#X}, addr(b) = {:#X}".format(id(a), id(b)))

c = 1
d = [12]
print(">>>before")
print("addr(c) = {:#X}, addr(d) = {:#X}".format(id(c), id(d)))
foo(c, d)
print(">>>after")
print("c = {0}, d = {1}".format(c, d))

>>>before
addr(c) = 0X560BA944AE80, addr(d) = 0X7F9D78C13108
>>>parameter passing
addr(a) = 0X560BA944AE80, addr(b) = 0X7F9D78C13108
>>>assignments
addr(a) = 0X560BA944AEA0, addr(b) = 0X7F9D78C13108
>>>after
c = 1, d = [12, 1]

线性表

发表于 2018-02-26 | 分类于 技术 , 数据结构

线性表


  • 顺序表
  • 链表

1.顺序表

1
2
3
4
5
6
7
8
#define LIST_INIT_SIZE  10 /* 线性表存储空间的初始分配量 */
#define LIST_INCREMENT 2 /* 线性表存储空间的分配增量 */
typedef struct
{
ElemType *elem; /* 存储空间基址 */
int length; /* 当前长度 */
int list_size; /* 当前分配的存储容量(以sizeof(ElemType)为单位) */
}SqList;

2.链表

内存管理

发表于 2018-02-26 | 分类于 技术

未完待续

Derive backpropagation

发表于 2018-02-26 | 分类于 机器学习 , 神经网络

Derive backpropagation


1 Forward Propagation

\[\boldsymbol a^l = \sigma(\boldsymbol z^l)\]

\[\boldsymbol z^l =\boldsymbol w^l\boldsymbol a^{l-1} + \boldsymbol b^l\]

non-vectored form

\[a_j^l = \sigma(z_j^l)\]

\[z_j^l =\sum_k w_{jk}^la_k^{l-1} + b_j^l\]

2 Backward Propagation

\[ \delta^l_j \equiv \frac{\partial C}{\partial z^l_j}\]

1
delta衡量的是对神经元输出激励值的误差

\[\boldsymbol \delta^L = \frac{\partial C}{\partial \boldsymbol a^L} \odot \sigma'(\boldsymbol z^L) = \nabla_a C \odot \sigma'(\boldsymbol z^L) \tag{1} \]

\[\boldsymbol \delta^l = ((\boldsymbol w^{l+1})^T \boldsymbol \delta^{l+1}) \odot \sigma'(\boldsymbol z^l) \tag{2}\]

\[ \frac{\partial C}{\partial b^l} = \delta^l \tag{3}\]

\[\frac{\partial C}{\partial w^l_{jk}} = \delta^l_j a^{l-1}_k \tag{4}\]

1
a(in)是输⼊给权重w的神经元的激活值,δ(out)是输出⾃权重w的神经元的误差,那么代价函数对参数w的偏导如下:

3 Proof and Derivation

  • 3.1 The first equation \[\begin{align} \delta^L_j &= \sum_k \frac{\partial C}{\partial a^L_k} \cdot \frac{\partial a^L_k}{\partial z^L_j} \\ &= \frac{\partial C}{\partial a^L_j} \cdot \frac{\partial a^L_j}{\partial z^L_j} \\ &= \frac{\partial C}{\partial a^L_j} \sigma'(z^L_j) \end{align}\]
1
当j不等于k时,a(k)对z(j)偏导为0
  • 3.2 The second equation

\[\begin{align} \delta^l_j &= \frac{\partial C}{\partial z^l_j} \\ &= \frac{\partial C}{\partial a^l_j} \cdot \frac{\partial a^l_j}{\partial z^l_j} \\ &= \frac{\partial C}{\partial a^l_j} \sigma'(z^l_j) \\ &= \sum_k \frac{\partial C}{\partial z^{l+1}_k} \cdot \frac{\partial z^{l+1}_k}{\partial a^l_j} \cdot \sigma'(z^l_j) \\ &= \sum_k \delta^{l+1}_k w_{kj} \sigma'(z^l_j) \end{align}\]

  • 3.3 The third equation

\[\begin{align} \frac{\partial C}{\partial b^l_j} &= \frac{\partial C}{\partial z^l_j} \cdot \frac{\partial z^l_j}{\partial b^l_j} = \frac{\partial C}{\partial z^l_j} \cdot 1 = \delta^l_j \end{align}\]

  • 3.4 The fourth equation \[\begin{align} \frac{\partial C}{\partial w^l_{jk}} &= \frac{\partial C}{\partial z^l_j} \cdot \frac{\partial z^l_j}{\partial w^l_{jk}} \\ &= \delta^l_j \cdot \frac{\partial z^l_j}{\partial w^l_{jk}} \\ &= \delta^l_j \cdot \frac{\partial (\sum_k a^{l-1}_k w^l_{jk}+b^l_j)}{\partial w^l_{jk}} \\ &= \delta^l_j a^{l-1}_k \end{align}\]

Reference

cuda及nvidia驱动安装

发表于 2018-02-26 | 分类于 工具

cuda及nvidia驱动安装


1. Install nvidia driver

  • dependences
1
2
3
apt install dkms build-essential linux-headers-amd64(or linux-headers-$(uname -r))
dpkg --add-architecture i386
apt install lib32z1 lib32ncurses5
  • disable nouveau module(optional)

    • vim /etc/modprobe.d/blacklist-nouveau.conf
    1
    2
    blacklist nouveau
    options nouveau modeset=0
    • update module
    1
    update-initramfs -u
  • execute installer

1
2
service lightdm stop // service gdm3 stop
sh NVIDIA-Linux-x86_64-XX.run -no-opengl-files

2. Install cuda/cudnn

1
2
3
sh cuda_XX.run
echo "/usr/local/cuda/lib64">>/etc/ld.so.conf.d/libcuda.conf
ldconfig

3. Issues

  • nvidia driver 登录管理器循环登录问题
1
2
// bios 安全登录问题
# sh ./NVIDIA-xxx.run -no-x-check -no-nouveau-check -no-opengl-files
  • cuda install Can't locate InstallUtils.pm in @INC
1
export PERL5LIB=.

Install Caffe

发表于 2018-02-26 | 分类于 Caffe

Caffe Install for Debian/Ubuntu

1. System Install(amd64)

2. Install Dependences

1
2
3
4
5
apt install gcc g++ make cmake cmake-curses-gui
apt install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler libgflags-dev libgoogle-glog-dev liblmdb-dev
apt install --no-install-recommends libboost-all-dev
apt install libatlas-base-dev
apt install python-dev python-skimage python-protobuf python-opencv

3. Install nvidia driver

4. Install cuda/cudnn

5. Compile Caffe

Issues

  • compile caffe

  1. Can't find hdf5
1
add path "/usr/include/hdf5/serial/","/usr/lib/x86_64-linux-gnu/hdf5/serial/" in Makefile.config
  1. undefined reference to ‘H5LTget_dataset_ndims’xx
1
vim cmake/Dependencies.cmake to append ${HDF5_HL_LIBRARIES}
  1. gcc/g++ version conflict
  • such as undefined reference to `google::base::CheckOpMessageBuilder::NewStringabi:cxx11'
1
2
3
4
5
6
7
8
9
10
11
12
13
## compile glog manually
apt purge libgoogle-glog-dev libgoogle-glog0v5
apt source libgoogle-glog-dev
cd google-glog-0.3.4
./configure

vim Makefile
#change line 613 to ACLOCAL=aclocal-1.15
#change line 619 to AUTOMAKE=automake-1.15
make
automake --add-missing
make -j 16
make install
12

Jiawei Cao

11 日志
9 分类
19 标签
© 2018 Jiawei Cao
由 Hexo 强力驱动
|
主题 — NexT.Mist v5.1.4