
Caffe
机器学习的小学生
这个作者很懒,什么都没留下…
展开
-
mnist example for lstm in caffe
下面给出在caffe中使用lstm的一个例子,其中数据集采用mnist。在使用lstm中一定要注意clip_markers,每个序列以0开始,后面接1保持为当前序列。训练代码为:train_mnist_classification.py#coding=gbkimport numpy as npimport matplotlib.pyplot as pltimport scipy.i...原创 2019-03-15 21:01:07 · 1071 阅读 · 0 评论 -
Caffe: create a simple sin layer
// test new_creat layer#include<iostream>#include<string>#include<vector>#include<opencv2/opencv.hpp>#include<caffe/caffe.hpp>#include"caffe_reg.h"#include"sin_lay.原创 2018-03-10 15:40:23 · 314 阅读 · 0 评论 -
caffe 读取数据
通常为了利用多标签数据(大部分网上介绍的),将数据准备为HDF5格式。 然而存储为HDF5数据通常采用single单精度,或者double双精度类型,使得数据量 动不动就几个G或者几十个G,然而,同一图像数据,准备不同尺度,都需要再度生成HDF5数据格式。然而另外一个简洁的方式是,定义一个读取数据的python层,用来处理数据,有时间的话,在回来补充完整。原创 2017-12-26 09:47:50 · 1794 阅读 · 0 评论 -
当batch_size 很大时,可以通过设置iter_size实现
In the solver.prototxt additer_size: 2That will mean that it would do 2 iterations of batch_size: 30 before updating the weights. This means that effectively you would using a batch_size: 60.You can c原创 2017-12-05 15:53:44 · 3546 阅读 · 0 评论 -
Caffes 21 天-在工程中使用caffe库
VS2015新建VS工程,根据自己实际的目录进行下面的配置(即类似于Caffe工程中matlab子工程的配置拷贝)。(1)配置包含目录:E:\caffe-windows\srcE:\caffe-windows\scripts\build\libraries\include\boost-1_61E:\caffe-windows\scripts\build\libraries\includeE:\原创 2017-03-15 16:00:51 · 2406 阅读 · 0 评论 -
利用程序写caffe协议:同名层
利用程序写协议,最大的困难在于:同名层的书写:# coding=gbkfrom caffe import layers as L, params as Pimport caffens = caffe.NetSpec()ns.Features,ns.Headposes,ns.Smiles = L.Data(name="data", ntop=3, include原创 2017-11-23 19:40:18 · 431 阅读 · 0 评论 -
caffe,tensorflow,theano,pytorch 输入数据形状
caffe : nsample * channels * height * widthlabels start from 0, such as for 5 classes, [0,1,2,3,4]; channels: BGR tensorflow:nsample * height * width * channelslabels start from 0, such a...原创 2017-11-11 15:29:18 · 1184 阅读 · 2 评论 -
VS2015+caffe+matlab+python+CPU
实验平台:Win7 64bit, VS 2015(Professional), matlab 2016b(64bit), python2.7.12, Eclipse IDE for Java Developers(Version: Neon.1a Release (4.6.1)),Cmake 3.8.0, protoc-3.1.0-windows-x86_64 ,boost_1_61_0-m...原创 2017-03-09 10:25:22 · 8095 阅读 · 5 评论 -
参数的初始化
训练自己的神经网络中,参数W和b的初始化:W = 0.01 * np.random.randn(D,K) # D是维数,K是类别数b = np.zeros((1,K))参考文献 13 CS231 Training a Simple Neural Network原创 2017-09-07 11:19:17 · 1258 阅读 · 0 评论 -
caffe 定义自己的python层
因为caffe底层是用c++编写的,所以我们有的时候想要添加某一个最新文献出来的新算法,正常的方法是直接编写c++网络层,然而这个有个前提条件是必须对caffe的底层非常熟悉,c++的编写达到一定的境界,才可灵活应用caffe,搞深度学习,走这条路对于菜鸟来说无疑很有难度。好在caffe为我们提供了一个可以用python编写新的网络层的方法,直接用python语言编写新的网络层,然后在caffe的网原创 2017-06-14 16:19:22 · 2817 阅读 · 2 评论 -
VGG16
Models from the BMVC-2014 paper “Return of the Devil in the Details: Delving Deep into Convolutional Nets”The models are trained on the ILSVRC-2012 dataset. The details can be found on the project p...原创 2018-03-03 10:46:06 · 2950 阅读 · 0 评论 -
Caffe C++新建层编译与调试
实验环境: vs2013, python2.7(Miniconda2),Windows10, cuda8.0感觉用windows系统做深度学习就是败笔。 以前用caffe提供的python接口,利用python层新建层,但是新建的层不支持GPU。因此需要自己动手写GPU的C++代码。面临的问题对C++的各个接口不是太熟悉,这是其一,其二习惯了python中数据的输入方式,例如使用HDF5或者...原创 2018-03-14 14:48:17 · 806 阅读 · 0 评论 -
lstm in caffe
// Message that stores parameters used by RecurrentLayermessage RecurrentParameter { // The dimension of the output (and usually hidden state) representation -- // must be explicitly set to non-z...原创 2019-03-06 21:28:36 · 856 阅读 · 0 评论 -
argmax in DNN
1 . 网址: https://www.reddit.com/r/MachineLearning/comments/4e2get/argmax_differentiable/原创 2018-11-21 21:26:09 · 476 阅读 · 0 评论 -
L.Tile layer in Caffe
test_tile_layer.py#coding=gbkimport numpy as npimport caffe# weight_file can be any prtrained modelsweight_file = '../attention_network/snapshots_aflw_vgg16_klLoss_finetune_attention1/cross1/vgg...原创 2018-11-13 20:31:02 · 1720 阅读 · 1 评论 -
AttributeError: 'Function' object has no attribute 'fn' [in caffe]
n.global_pool_prob3 = L.Sigmoid(n.global_pool_up3,name='global_pool_prob3',ntop=0,top='global_pool_up3') n.att_repmat3 = L.Tile(n.global_pool_prob3,tile_param={'axis':1,'tiles':256})报错产生的原因是,下一层使用的...原创 2018-11-01 09:20:30 · 3788 阅读 · 0 评论 -
eltwise sum over multiple channels 逐通道的相加in Caffe
//sum over 16 channelslayers { name: "sum_1" type: CONVOLUTION bottom: "conv_1" top: "sum_1" blobs_lr: 0 convolution_param { num_output: 1 bias_term: false kernel_size: 1 ...原创 2018-11-01 08:59:23 · 1268 阅读 · 0 评论 -
caffe + python + float 产生 Inf ,从而触发NaN
损失函数在训练过程中,如果在刚开始的迭代过程中损失函数就发散变为了Inf 或者NaN,那么往往可以通过调节学习率来解决。另外一种情况是在迭代了数千次,例如我迭代了1800次,忽然出现损失函数为Inf或者NaN的情况,在我的实验情况下是由于caffe的python接口使用的是单精度float类型,在自己用python定义的层中,使用到了指数函数np.exp(a),当a的 值超过某个数时例如90,...原创 2018-06-13 11:12:40 · 1016 阅读 · 0 评论 -
Caffe Scale层
如果我们想原封不动的传送数据,也就是说建一个不做任何操作仅穿数据的层,可以利用Scale层,Python中写法如下: n.scale1 = L.Scale(n.pool2,name='scale1',param=dict(lr_mult=0),filler=dict(type="constant",value=1))生成的prototxt协议文件如下:layer { name:...原创 2018-05-08 19:31:27 · 10230 阅读 · 0 评论 -
Caffe+Python2.7+Window10 只报错运行时错误,不提示错误的详细信息
使用:Caffe+Python2.7+Window10 时,在eclipse或者pycharm的环境下,Caffe报错不提示错误的详细信息,仅给出下面的错误信息:I0508 10:57:00.947213 15508 net.cpp:139] Memory require*** Check failure stack trace: ***但是:Caffe + Python2.7 + Win...原创 2018-05-08 19:22:00 · 502 阅读 · 0 评论 -
Normalize Layer in Caffe
message NormalizeParameter { optional bool across_spatial = 1 [default = true]; // Initial value of scale. Default is 1.0 for all optional FillerParameter scale_filler = 2; // Whether or not s...原创 2018-05-12 21:40:17 · 4592 阅读 · 0 评论 -
convert vgg-face model weight from caffe to pytorch
#coding=UTF-8import torch import torch.nn as nnimport mathimport numpy as npfrom PIL import Image,ImageDrawimport matplotlib.pyplot as pltimport collectionsimport matplotlib.cm as cmfrom tor...原创 2018-05-02 21:27:46 · 1531 阅读 · 0 评论 -
Win7 安装 VS 2015 运行C++时提示ucrtbased.dll丢失 的解决方法
This problem is from VS 2015 silently failing to copy ucrtbased.dll (debug) and ucrtbase.dll (release) into the appropriate system folders during the installation of Visual Studio. (Or you did not sele原创 2017-09-06 09:44:19 · 10173 阅读 · 1 评论 -
caffe 进行简单的训练和测试
通过编译生成在目录E:\caffe-windows\scripts\build\tools\Release下的两个可执行文件:convert_imageset.exe #将图像转换格式compute_image_mean.exe # 计算图像的均值文件生成对应的leveldb格式数据convert_imageset.exe [train_image_dir] [train_txt] [out_原创 2017-03-11 10:05:34 · 717 阅读 · 0 评论 -
How to write Lossfunction in PythonCaffe
在Python 中自定义层:原创 2017-08-18 20:42:18 · 662 阅读 · 0 评论 -
lenet and caffe-lenet
方法1:代码测试下面的代码测试caffe-lenet中权重w,b以及bottom,up数据大小变化的情况。理解caffe-lenet中的具体实现。并对mnist数据集进行了测试。对于caffe生成的mean.binaryproto文件其在matlab中同样遵循[width * height *c]以及bgr模式。实现需要的文件:mnist数据集的 :mean.binaryproto文件,mnist_原创 2017-04-12 11:09:58 · 511 阅读 · 0 评论 -
caffe: unknown layer type/unknown solver type
Only for windowscaffe 通过定义静态全局对象的形式(利用对象的构造函数),来创建一个静态类型的变量map<type,creator>来存储其所支持的层类型和解决器类型:static LayerRegisterer<float> g_creator_f_##type(#type, creator<float>); static LayerRegisterer<double>原创 2017-03-18 17:12:19 · 5457 阅读 · 3 评论 -
模板分离编译模式和工厂模式
#define INSTANTIATE_CLASS(classname) \ char gInstantiationGuard##classname; \ template class classname<float>; \ template class classname<double>#define REGISTER_LAYER_CREATOR(type, creator)原创 2017-03-30 16:44:36 · 1713 阅读 · 1 评论 -
Caffe训练过程:test_iter test_interval等概念
先上一张图,大家很熟悉的一张图。 首先说明一个概念:在caffe中的一次迭代iteration指的是一个batch,而不是一张图片。下面就主要说下2个概念 test_iter: 在测试的时候,需要迭代的次数,即test_iter* batchsize(测试集的)=测试集的大小,测试集batchsize可以在prototx文件里设置 test_interval:interval是区间的意思,所有转载 2017-03-24 17:00:15 · 2549 阅读 · 0 评论 -
how to force global variable which define in a static library to initialize?
参考文献:https://www.gamedev.net/topic/622861-how-to-force-global-variable-which-define-in-a-static-library-to-initialize/ http://gamedev.stackexchange.com/questions/37813/variables-in-static-library-are原创 2017-03-31 18:06:04 · 694 阅读 · 0 评论 -
caffe/matalb/python中数据的存储方式
caffe/matalb/python中数据的存储方式下面的代码摘自:classification_demo.m% Usage:% im = imread('../../examples/images/cat.jpg');% scores = classification_demo(im, 1);% [score, class] = max(scores);% Five things原创 2017-03-23 16:57:45 · 907 阅读 · 0 评论 -
参看caffe中三通道彩色图像的卷积过程
E:\caffe-windows-lib\matlab\hdf5creation\predict_label_testdata_for_analysis.m代码:clearvars;close all;if ~exist('ttest_data','var')||~exist('means','var') test_data = load('ttest_data.mat'); % load原创 2017-04-08 15:51:45 · 4660 阅读 · 0 评论 -
生成hdf5文件用于多标签训练
1.python 2.matlab参考文献:1.http://blog.youkuaiyun.com/u011762313/article/details/48830561 [ 生成hdf5文件用于多标签训练]原创 2017-03-23 11:03:34 · 3130 阅读 · 1 评论 -
由train_val.prototxt 生成deploy.prototxt
1.train_val.prototxt文件是网络配置文件。该文件是在训练的时候用的。deploy.prototxt该文件是在测试时使用的文件[1]。 2.用训练好的caffemodel来测试单张图片需要一个deploy.prototxt文件来指定网络的模型构造[2]。参考文献: 1. http://blog.youkuaiyun.com/fx409494616/article/details/530089原创 2017-03-13 15:24:04 · 1283 阅读 · 0 评论 -
caffe实现多标签输入(multilabel、multitask)
其他资料以下内容摘自参考文献[2],将caffe中的data和label分别写在两个layer中:layer { name: "data" type: "Data" top: "data" include { phase: TRAIN } transform_param { mean_value: 104.00699 mean_value: 116.6原创 2017-03-22 10:32:14 · 1657 阅读 · 0 评论 -
Caffe中Loss Layer原理的简单梳理
转自:http://blog.youkuaiyun.com/liumaolincycle/article/details/50822392 [liumaolincycle的博客] 1.SoftmaxWithLoss对一对多的分类任务计算多项逻辑斯蒂损失,并通过softmax传递预测值,来获得各类的概率分布。该层可以分解为SoftmaxLayer+MultinomialLogisticLossLa转载 2017-04-05 09:53:27 · 626 阅读 · 0 评论 -
Caffe中math_functions 分析
转载自:[Caffe源码(一):math_functions 分析](http://blog.youkuaiyun.com/seven_first/article/details/47378697#1-caffecpugemm-%E5%87%BD%E6%95%B0) 目录目录主要函数caffe_cpu_gemm 函数caffe_cpu_gemv 函数caffe_axpy 函数caffe_转载 2017-04-14 21:19:15 · 463 阅读 · 0 评论 -
caffe 自定义层/添加自己的损失函数
自定义激活层文献[2] 以循序渐进的学习方式先后介绍了: google protocol buffe , Blob ,SyncedMemory ,shared_ptr ,layer,data layer 然后利用这些知识来自定义一个层。其给出的例子是定义一个power层,可以通过caffe的api参考其结构:http://caffe.berkeleyvision.org/doxygen/cla原创 2017-03-12 10:17:37 · 9694 阅读 · 1 评论 -
caffe 安装时提示cudnn.hpp(114): too few arguments in function call
问:Try to build Caffe with GPU and MATLAB support. However, when I use build_win.cmd to install, It can’t build and with the error :“D:\caffe-windows\caffe-windows\scripts\build\ALL_BUILD.vcxproj” (def原创 2017-06-22 11:25:46 · 6625 阅读 · 0 评论 -
Caffe 网络结构可视化
1.在线可视化Caffe:主入口: http://ethereon.github.io/netscope/quickstart.html快捷入口: http://ethereon.github.io/netscope/#/editor2.利用 python/draw_net.py 可视化。1.下载 protobuf-3.1.0-py2.py3-none-any.whlpip install pr原创 2017-03-15 15:36:29 · 1769 阅读 · 0 评论