MISC (TMP NOTES)
- sucks
@
深度学习源码解读-ch2-Caffe is coming - 黑客与画家 - 知乎专栏
proto txt,
深度学习源码解读-ch3-部署 Caffe 网络 - 黑客与画家 - 知乎专栏
通过这个实际的例子,我们再去看proto.txt就容易多了,知道根节点是Net,我们就可以从源码中看到调用关系,以netparam为例:
ReadNetParamsFromTextFileOrDie -> ReadProtoFromTextFile -> 5行反序列化代码。
Solveparam有类似的层次结构,grep一下代码不难理清调用关系。
深度学习源码解读-ch4-Caffe 中的设计模式 - 黑客与画家 - 知乎专栏
我们可以挑EUCLIDEAN LOSS Layer为例,看看caffe中加入一个自定义层,需要多少的工作量。
caffe使用了工厂模式,代码在 layer_factory.hpp 中,宏 REGISTER_LAYER_CLASS 为每个type生成了create方法,并和type一起注册到了 LayerRegistry中,保存在一个map里面。这样以后就可以通过Type,我们就能够创建带forward/backward实现的节点了。
对于forward,就是在计算欧式距离,假设网络输出向量为 [x1, x2, … xn], label为 [l1, l2, … ln], 则loss function 为
½ *[ (x1 – l1)(x1-l1) + … (xn -ln)(xn -ln)] / n
所以代码实现是一个向量的减法,紧跟着一个点乘,以CPU为例是:
caffe_sub(count, bottom[0]->cpu_data(), bottom[1]->cpu_data(), diff_.mutable_cpu_data()); Dtype dot = caffe_cpu_dot(count, diff_.cpu_data(), diff_.cpu_data()); Dtype loss = dot / bottom[0]->num() / Dtype(2);
- caffe开发过程中使用了哪些工具? - 软件开发 - 知乎
@
作者:贾扬清
还是挺标准的 linux 开发流程:
- 编辑器:vim(因为要远程在服务器上编辑)+ Sublime Text(本地编辑)
- 编译:gcc + nvcc + Makefile
- 调试:gdb + cuda-gdb (cuda-gdb 用得很少),valgrind
- 调试 cuda 代码速度:nvvp
- 代码管理:git + github
补充一些不是那么相关的:
- 远程 ssh 自动重连:mosh
- 命令行下多窗口:tmux
- 偶尔需要用到的 vnc:TigerVNC server + Chicken (mac client)
- 本地多种环境的集成测试:docker(当年没用到,后来开始用)
- 服务器上的集成测试:Travis CI
主要用到的 dependency:
- glog:打印调试信息,这个对于调错很有用。
- gflags:命令行参数
- gtest:测试框架
- protobuf:数据的序列化
- boost:一些类似 C++11 的 feature,因为早期 cuda 不支持 c++11
- opencv:图像处理函数
- leveldb,lmdb:简单的本地数据库。
- cuda:这个就不用说了
- atlas/mkl/eigen:线性代数计算库
downloads
- CVPR 2016 有什么值得关注的亮点? - 深度学习(Deep Learning) - 知乎
nothing special.
- 对人工智能有着一定憧憬的计算机专业学生可以阅读什么材料或书籍真正开始入门人工智能的思路和研究? - 计算机科学 - 知乎
too good! too much!
李飞飞:如何教计算机理解图片_李飞飞:如何教计算机理解图片_网易公开课
简短地回答是: 这是因为微软十年如一日地烧钱养了一个叫微软研究院的机构,里面一帮科学家不用做产品没事干天天琢磨怎么把科幻变成现实。终于碰上个能放到产品里了,产品的硬实力立马把没有科研积累的苹果和谷歌甩了一大截(当然市场表现另论)。
除了我说的两种很厉害的学者之外,还有两种 vision 的研究者。第一种是“性能挂帅”:今天整个 HOG+SIFT,明天换个 boosting 的目标函数,后天再来个局部特征 + 整体特征;别人发现了 deep learning 管用了自己马上也摇身变成了 deep learning 的砖家,跟在别人后面用现有的技术把性能从 81% 做到 82% 就开始在社交网络上吹嘘自己实现了里程碑,超越了谷歌 MIT。这不是做研究,这是山寨。第二种是“数学挂帅”。遇到这种老板更要趁早退学或者转行,否则学术界工业界的工作都不好找。大家对号入座,看看自己和自己的导师是哪一种 :)
getSelection().toString()
, or "*p
此外有人提到了 Feifei 对学生的态度。有个故事,到 Feifei 的主页上查学生去向,在一群硅谷 scientist,professor 中间有一个空白的,这个人去了街上,收入是其他人的和。
使用同样模式运营的 lab(青睐国内优秀本科毕业生,要求动手能力强,做大量实验)的华人 CV 大牛还有 UCLA 的朱松纯、NUS 的颜水城等。
- What does “xavier” mean? · Issue #1537 · BVLC/caffe
- andy’s blog — An Explanation of Xavier Initialization
print("Accuracy: {:.3f}".format(accuracy));
- include/solver.prototxt
@
net: "models/finetune_flickr_style/train_val.prototxt" test_iter: 100 test_interval: 1000 # lr for fine-tuning should be lower than when starting from scratch base_lr: 0.001 lr_policy: "step" gamma: 0.1 # stepsize should also be lower, as we're closer to being done stepsize: 20000 display: 20 max_iter: 100000 momentum: 0.9 weight_decay: 0.0005 snapshot: 10000 snapshot_prefix: "models/finetune_flickr_style/finetune_flickr_style" # uncomment the following to default to CPU mode solving # solver_mode: CPU
- models/finetune_flickr_style/train_val.prototxt
@
name: "FlickrStyleCaffeNet" layer { name: "data" type: "ImageData" top: "data" top: "label" include { phase: TRAIN } transform_param { mirror: true crop_size: 227 mean_file: "data/ilsvrc12/imagenet_mean.binaryproto" } image_data_param { source: "data/flickr_style/train.txt" batch_size: 50 new_height: 256 new_width: 256 } } layer { name: "data" type: "ImageData" top: "data" top: "label" include { phase: TEST } transform_param { mirror: false crop_size: 227 mean_file: "data/ilsvrc12/imagenet_mean.binaryproto" } image_data_param { source: "data/flickr_style/test.txt" batch_size: 50 new_height: 256 new_width: 256 } } layer { name: "conv1" type: "Convolution" bottom: "data" top: "conv1" param { lr_mult: 1 decay_mult: 1 } param { lr_mult: 2 decay_mult: 0 } convolution_param { num_output: 96 kernel_size: 11 stride: 4 weight_filler { type: "gaussian" std: 0.01 } bias_filler { type: "constant" value: 0 } } } layer { name: "relu1" type: "ReLU" bottom: "conv1" top: "conv1" } layer { name: "pool1" type: "Pooling" bottom: "conv1" top: "pool1" pooling_param { pool: MAX kernel_size: 3 stride: 2 } } layer { name: "norm1" type: "LRN" bottom: "pool1" top: "norm1" lrn_param { local_size: 5 alpha: 0.0001 beta: 0.75 } } layer { name: "conv2" type: "Convolution" bottom: "norm1" top: "conv2" param { lr_mult: 1 decay_mult: 1 } param { lr_mult: 2 decay_mult: 0 } convolution_param { num_output: 256 pad: 2 kernel_size: 5 group: 2 weight_filler { type: "gaussian" std: 0.01 } bias_filler { type: "constant" value: 1 } } } layer { name: "relu2" type: "ReLU" bottom: "conv2" top: "conv2" } layer { name: "pool2" type: "Pooling" bottom: "conv2" top: "pool2" pooling_param { pool: MAX kernel_size: 3 stride: 2 } } layer { name: "norm2" type: "LRN" bottom: "pool2" top: "norm2" lrn_param { local_size: 5 alpha: 0.0001 beta: 0.75 } } layer { name: "conv3" type: "Convolution" bottom: "norm2" top: "conv3" param { lr_mult: 1 decay_mult: 1 } param { lr_mult: 2 decay_mult: 0 } convolution_param { num_output: 384 pad: 1 kernel_size: 3 weight_filler { type: "gaussian" std: 0.01 } bias_filler { type: "constant" value: 0 } } } layer { name: "relu3" type: "ReLU" bottom: "conv3" top: "conv3" } layer { name: "conv4" type: "Convolution" bottom: "conv3" top: "conv4" param { lr_mult: 1 decay_mult: 1 } param { lr_mult: 2 decay_mult: 0 } convolution_param { num_output: 384 pad: 1 kernel_size: 3 group: 2 weight_filler { type: "gaussian" std: 0.01 } bias_filler { type: "constant" value: 1 } } } layer { name: "relu4" type: "ReLU" bottom: "conv4" top: "conv4" } layer { name: "conv5" type: "Convolution" bottom: "conv4" top: "conv5" param { lr_mult: 1 decay_mult: 1 } param { lr_mult: 2 decay_mult: 0 } convolution_param { num_output: 256 pad: 1 kernel_size: 3 group: 2 weight_filler { type: "gaussian" std: 0.01 } bias_filler { type: "constant" value: 1 } } } layer { name: "relu5" type: "ReLU" bottom: "conv5" top: "conv5" } layer { name: "pool5" type: "Pooling" bottom: "conv5" top: "pool5" pooling_param { pool: MAX kernel_size: 3 stride: 2 } } layer { name: "fc6" type: "InnerProduct" bottom: "pool5" top: "fc6" param { lr_mult: 1 decay_mult: 1 } param { lr_mult: 2 decay_mult: 0 } inner_product_param { num_output: 4096 weight_filler { type: "gaussian" std: 0.005 } bias_filler { type: "constant" value: 1 } } } layer { name: "relu6" type: "ReLU" bottom: "fc6" top: "fc6" } layer { name: "drop6" type: "Dropout" bottom: "fc6" top: "fc6" dropout_param { dropout_ratio: 0.5 } } layer { name: "fc7" type: "InnerProduct" bottom: "fc6" top: "fc7" # Note that lr_mult can be set to 0 to disable any fine-tuning of this, and any other, layer param { lr_mult: 1 decay_mult: 1 } param { lr_mult: 2 decay_mult: 0 } inner_product_param { num_output: 4096 weight_filler { type: "gaussian" std: 0.005 } bias_filler { type: "constant" value: 1 } } } layer { name: "relu7" type: "ReLU" bottom: "fc7" top: "fc7" } layer { name: "drop7" type: "Dropout" bottom: "fc7" top: "fc7" dropout_param { dropout_ratio: 0.5 } } layer { name: "fc8_flickr" type: "InnerProduct" bottom: "fc7" top: "fc8_flickr" # lr_mult is set to higher than for other layers, because this layer is starting from random while the others are already trained param { lr_mult: 10 decay_mult: 1 } param { lr_mult: 20 decay_mult: 0 } inner_product_param { num_output: 20 weight_filler { type: "gaussian" std: 0.01 } bias_filler { type: "constant" value: 0 } } } layer { name: "accuracy" type: "Accuracy" bottom: "fc8_flickr" bottom: "label" top: "accuracy" include { phase: TEST } } layer { name: "loss" type: "SoftmaxWithLoss" bottom: "fc8_flickr" bottom: "label" top: "loss" }
- rbgirshick (Ross Girshick)
@
rbg
- rbgirshick/fast-rcnn: Fast R-CNN
@
790 stars.
- rbgirshick/fast-rcnn: Fast R-CNN
结束语: 选择专业方向和博士导师是改变你人生轨迹的抉择, 绝非游戏,望你慎重考虑, 谋定而动, 锲而不舍。 你最好认真浏览本实验室的活动、demo、科研项目,多读几篇论文, 问你自己是否愿意长期投身这个方向。“道不同,不相为谋”,如果你不确定、还没想好, 最好不要报, 更不要谎报。