plutolove’s diary

I love three things in this world, the sun, the moon and you. The sun for the day, the moon for the night, and you forever。

配置PostgreSQL调试环境

首先下载PostgreSQL源码,我用的是PostgreSQL9.4.2。

  • /home/username/新建pg文件夹,然后在.bashrc文件内添加
#每次更改.bashrc之后,执行
source ~/.bashrc
export PG=/home/username/pg
  • 在源代码文件夹下执行
./configure --prefix=$PG --enable-depend --enable-cassert --enable-debug
make install
  • 为了方便调试运行在.bashrc内添加
export PATH=$PATH:/home/username/pg/bin
Read more

MIT 6.824 Lab1 MapReduce

MapReduce

MapReduce是Google提出的一种分布式编程框架,具体介绍看MapReduce论文

MIT 6.824 Lab1要求使用Go语言实现一个简易版本的MapReduce框架,在实现之前先通过下图了解MapReduce的执行过程

f:id:plutolove:20170329153559p:plain 以实验1的wordcount为例,首先将输入文件分成5份,用户规定Map操作和Reduce操作的数量设为mrMapReduce操作用用户自己定义,由Master5个文件分配给3worker,每一个执行Map操作的worker将生成r个中间文件(key,val),Map操作要保证相同key值的数据在同一个文件中,然后执行Reduce操作,每个Reduce产生一个文件

Read more

Linear Regression

  • 線性迴歸模型:$h_\theta(x) = \theta * x$

  • 參數$\theta = (\theta_0, \theta_2, ..., \theta_n)$

  • Cost Function爲:$J(\theta) = \frac{1}{2} \sum_i \left( h_\theta(x^{(i)}) - y^{(i)} \right)2$

m爲訓練集的大小,解線性迴歸模型即就是求出最小的Cost Function對應的$\theta$值

Read more