Posts

Stanford's CS231n Lecture 5 Convolutional Neural Networks 笔记

Image
CS231n Lecture 5 Convolutional Neural Networks 的笔记 卷积神经网络 CNN 1. 卷积层 Convolutional Neural Layer : 我们以输入是一张32*32*3 的图像作输入为例,全连接的话,输入是一个(1,3072)的向量,然后乘以一个(10,3072)的权重矩阵,最后得到一个(1,10)的向量。然后把最后向量里的元素施加以激活函数。 然而在CNN卷积层里面,我们运算是这样的:拿一个5*5*3的filter w,在输入的图像上移动,每走一步,得到一个数字,这个数字是由图像上的那块5*5*3 和 w 的做dot product然后在加上bias得到的。注意:这里输入图像的厚度是3,那这里filter的厚度保持不变,也是3。最后我们得到的activation map的厚度是1 我们可以对原图进行多次这样的操作然后得到了多层这样的activation map 然后把这6个单层的activation map concat为一组,也就是下图的中间蓝色部分,可以看到它的厚度是6,左边粉色的厚度是3,从第一大块到第二大块,这里用了6个filters(5,5,3)。同理我们通过10个5*5*6的filter,把第二大块,(28,28,6),的这层再做CNN,得到了第三大块也就是(24,24,10) 在最后,不同大块上的东西也就提取到了不同的特征 这个过程之所以叫做*卷积*神经网络,是因为这个和信号处理里的卷积很相似。“如果大家学过信号处理应该能看得出来”小姐姐如是说道 - - 2. 在filter对前一层进行运算时候的细节: 方便起见,我们假设输入是(7,7,1) 然后有一个(3,3,1)的filter。每次移动的stride为2,在最后我们会得到一个3*3的输出(具体的厚度取决于filter的个数) 当输入的边长与filter的边长作差然后除以stride不能整除的时候,我们需要对输入进行padding(补全),不然的话就会漏掉最边角的像素。之于为什么padding的值是零,只是在尝试以后发现这样做没毛病- - 这一段最后的总结 3. CNN中的其他层(非卷积层) ...

Stanford's CS231n Lecture 11: Detection and Segmentation 笔记

Image
0. 主要内容 1. Semantic Segmentation 我们定义一系系列 label,比如天空,树木,猫,牛。然后对于输入图片的每个像素,输出一个预测的label值。 实现方式1: Fully Convolutional 但是对于高分辨率的图片 这样的过程是非常耗时的,于是我们进行了改进。 实现方式1 改: 这里我们用了downsampling 和 upsampling 来降低所需要处理的像素。 downsampling我们可以用pooling,strided convolution 来实现。 对于upsampling,这里介绍了两种方法: nearest neighbor 和 bed of nails (钉板) 在具体场景中,如果我们用bed of nails 来upsampling的话,不会像上图那样选取左上角来给值,而是根据在downsampling的时候取的那个像素位置来对应的还原。 2. Classification + Localization 例子1: 分类并定位图中的猫 输入一张图,输出一个矩形框的坐标。(x,y,w,h) 例子2: 姿势预测 我们可以用14个点来表示人体主要关节,于是我们只要在一个图片里识别出来这14个点,就大概确定了人的姿势。所以这里输入是一张图,输出是14个坐标。 tip: 这里的loss function 用的是regression loss。 在loss function的选择上,classification 和 regression 问题选用的有点差别 如果我们要的是一个类别输出,比如对几个类别的分类问题,这时候用的比较多的就是:cross entropy loss, softmax loss, SVM margin type loss  但是如果我们要的是一些连续的值,比如这里的点位,那么loss function 用L1, L2 距离比较合适。 3. Object Detection 这里和Classification问题的区别在于物体的数量。 3.1 CNN family 比较朴素的想法是滑窗,然后对选定的区域做分类/定位,比如用CNN。 ...

System Design Class 1

Image
Class 1: Macro Design,宏观设计方式: Crack a design in 5 steps:  " SNAKE "模式 Scenario: case / interface 场景 需求分析 枚举所有的需求 对所有的需求排序 Necessary: constrain / hypothesis 限制:用户、流量、内存 询问日访问量users (一般公司 100w,google 或者 facebook 可以上1000w 或者 上亿) 预测同时在线用户量,一般users / 5 预测高峰在线用户量,一般users * 3 可扩展性 预测三个月以后的日访问量,一般users * 10 流量的预测 请求频率 比如 1 message  / min 每次请求的流量大小 一首歌可能是3 Mb,facebook的话可以用浏览器调试工具来ka  峰值流量 = 用户在线峰值 * 3Mb * 1 / 60 = *** Mb / s 内存的预测 Application: service / algorithm Replay the case, add a service for each request merge the services: (比如豆瓣fm可以把 用户登录(user service) 频道请求(channel service) 播放请求(music service) 三个服务给合并) Kilobit: data 选择合适的存储方式 把每个服务和数据集对应 选择合适的数据集:这里user service因为添加固定,修改和删除都很少,所以可以用mysql存储;channel service列表数量很多可以用MongoDB;music service 可以直接用文件(File) 附加阅读: https://www.zhihu.com/question/23602133 https://www.zhihu.com/question/20059632 Evolve Analyze 把constrain提高,比如提供400Gb/s 怎么保障 新功能开发 内容更详细,比如用户想要注册登录注销屏蔽等功能 性能提升 鲁棒性,应急方案,比如服务器挂...

SICP Note Chapter 1

Image
1. S ubstitution model 代换模型( https://mitpress.mit.edu/sicp/full-text/sicp/book/node10.html ) 并不指实际中使用的,而是用于方便理解的一个较为粗糙的syntax analysis模型 其中代换分为正则序代换(normal-order evaluation, 把所有procedure 展开成基本运算符 最后运算) 以及应用序代换(applicative-order evaluation 先计算最外层procedure里的运算数的值 然后再展开procedure) 2. S ICP里对递归和迭代的解释 递归: (define (factorial n) (if (= n 1) 1 (* n (factorial (- n 1))))) 迭代: (define (factorial n) (fact-iter 1 1 n)) (define (fact-iter product counter max-count) (if (> counter max-count) product (fact-iter (* counter product) (+ counter 1) max-count))) This type of process, characterized by a chain of deferred operations, is called a recursive process. Carrying out this process requires that the interpreter keep track of the operations to be performed later on. In the computation of n!, the length of the chain of deferred multiplications, and hence the amount of information needed to keep track of it, grows linearly with n (is propo...

常见的排序算法及实现

本文配合 visualgo 食用更佳 堆排序 快速排序 归并排序 冒泡排序 选择排序 插入排序 堆排序 一般用一维数组来实现,为方便下标为0的位置空出,数据内容从下标为1开始。(如果要从0开始也是可行的) 迭代下面步骤: 调整乱序数组为一个大顶堆 交换下标为1(即最大的元素)与下标最后的元素内容,这时不满足堆的定义 调整剩余部分为大顶对 public class heapsort { public static void main ( String args []) { int [] num = new int [] { - 1 , 49 , 38 , 65 , 97 , 76 , 13 , 55 }; sort ( num ); for ( int i : num ) { System . out . print ( i + " " ); } } static void heapAdjust ( int start , int end , int [] array ) { int temp = array [ start ]; for ( int j = 2 * start ; j <= end ; j *= 2 ) { if ( j < end ) { // 说明还有右子树 if ( array [ j ] < array [ j + 1 ]) j += 1 ; // 让j指向左右子树中较大的那个 } if ( temp >= array [ j ]) // 满足大顶堆的要求不需要调整 break ; array [ start ] = array [ j ]; // 调整顶端与子树内容 start = j ; // 继续循环 } array [ start ] = temp ; } static void sort ( int [] num ) { ...