caffe学习记录(二)

继续layer的学习。

cafee中的卷积层:

layer {
  name: "conv1"
  type: "Convolution"
  bottom: "data"
  top: "conv1"
  param {
    lr_mult: 1
  }
  param {
    lr_mult: 2
  }
  convolution_param {
    num_output: 20
    kernel_size: 5
    stride: 1
    weight_filler {
      type: "xavier"
    }
    bias_filler {
      type: "constant"
    }
  }
}

param:只有一个为权重的学习率,两个的话第二个为bias的学习率,最终的学习率需要这个数乘以solver.prototxt配置文件中的base_lr。

num_output:卷积核个数

kernel_size": filter size,如果 h 和w不等,则用kenel_h 和kenel_w分别设定

weight_filter: constant为0, xavier,gaussian为初始化的算法

bias_filter: the same

输入:n*c0*w0*h0

输出:n*c1*w1*h1

其中,c1就是参数中的num_output,生成的特征图个数

w1=(w0+2*pad-kernel_size)/stride+1;

h1=(h0+2*pad-kernel_size)/stride+1;

pooling layer:

layer {
  name: "pool1"
  type: "Pooling"
  bottom: "conv1"
  top: "pool1"
  pooling_param {
    pool: MAX
    kernel_size: 3
    stride: 2
  }
}

LRN layer:

layers {
  name: "norm1"
  type: LRN
  bottom: "pool1"
  top: "norm1"
  lrn_param {
    local_size: 5
    alpha: 0.0001
    beta: 0.75
  }
}

im2col层:它先将一个大矩阵,重叠地划分为多个子矩阵,对每个子矩阵序列化成向量,最后得到另外一个矩阵。

在 caffe中,卷积运算就是先对数据进行im2col操作,在进行内积运算(inner product)。速度快

Activiation Layers:

1.Sigmoid: 没有额外参数

layer {
  name: "encode1neuron"
  bottom: "encode1"
  top: "encode1neuron"
  type: "Sigmoid"
}

2.RELU:

可选参数:

  negative_slope:默认为0. 对标准的ReLU函数进行变化,如果设置了这个值,那么数据为负数时,就不再设置为0,而是用原始数据乘以negative_slope

layer {
  name: "relu1"
  type: "ReLU"
  bottom: "pool1"
  top: "pool1"
}

3.tanh:

layer {
  name: "layer"
  bottom: "in"
  top: "out"
  type: "TanH"
}

softmax-loss layer:

layer {
  name: "loss"
  type: "SoftmaxWithLoss"
  bottom: "ip1"
  bottom: "label"
  top: "loss"
}

softmax layer:

layers {
  bottom: "cls3_fc"
  top: "prob"
  name: "prob"
  type: “Softmax"
}

Inner Product: 也就是全连接层:

layer {
  name: "ip1"
  type: "InnerProduct"
  bottom: "pool2"
  top: "ip1"
  param {
    lr_mult: 1
  }
  param {
    lr_mult: 2
  }
  inner_product_param {
    num_output: 500
    weight_filler {
      type: "xavier"
    }
    bias_filler {
      type: "constant"
    }
  }
}

3.预测层accuracy:

layer {
  name: "accuracy"
  type: "Accuracy"
  bottom: "ip2"
  bottom: "label"
  top: "accuracy"
  include {
    phase: TEST
  }
}

4.Reshape操作:

 layer {
    name: "reshape"
    type: "Reshape"
    bottom: "input"
    top: "output"
    reshape_param {
      shape {
        dim: 0  # copy the dimension from below
        dim: 2
        dim: 3
        dim: -1 # infer it from the other dimensions
      }
    }
  }

假设原数据为:64*3*28*28, 表示64张3通道的28*28的彩色图片

经过reshape变换:

   reshape_param {
      shape {
        dim: 0
        dim: 0
        dim: 14
        dim: -1
      }
    }

输出数据为:64*3*14*56

5. drop out:

layer {
  name: "drop7"
  type: "Dropout"
  bottom: "fc7-conv"
  top: "fc7-conv"
  dropout_param {
    dropout_ratio: 0.5
  }
}

原文地址:https://www.cnblogs.com/ChrisInsistPy/p/9583465.html

时间: 2024-08-29 21:52:53

caffe学习记录(二)的相关文章

Windows API 编程学习记录<二>

恩,开始写Windows API编程第二节吧. 上次介绍了几个关于Windows API编程最基本的概念,但是如果只是看这些概念,估计还是对Windows API不是很了解.这节我们就使用Windows API 让大家来了解下Windows API的用法. 第一个介绍的Windows API 当然是最经典的MessageBox,这个API 的作用就是在电脑上显示一个对话框,我们先来看看这个API的定义吧: int WINAPI MessageBox(HWND hWnd, LPCTSTR lpTe

Spring Boot学习记录(二)--thymeleaf模板

Spring Boot学习记录(二)–thymeleaf模板 标签(空格分隔): spring-boot 自从来公司后都没用过jsp当界面渲染了,因为前后端分离不是很好,反而模板引擎用的比较多,thymeleaf最大的优势后缀为html,就是只需要浏览器就可以展现页面了,还有就是thymeleaf可以很好的和spring集成.下面开始学习. 1.引入依赖 maven中直接引入 <dependency> <groupId>org.springframework.boot</gr

caffe学习记录

在深度学习零率,caffe是一个非常高效的的图像处理框架,结合了nvidia的cuda,cudnn加速技术,非常适合进行AI CNN方向的图像分类,回归,分割等. 但是由于caffe的教程较少,而且配置比较复杂,可能用的人没有tf那么广泛. 昨天在Ubantu14.04上配置了caffe, CUDA8.0, Cudnn5.1等,从今天开始进行caffe的学习记录总结. 跑完make all runtest后,如果运行成功,表示caffe环境配置好了. 首先测试一下minist60000+1000

netty 学习记录二

netty 最新版本是netty-5.0.0.Alpha1,去年10月份发布的,至今没有发新版本,估计这个版本还是比较稳定. 整包下载,里面包含一个 netty-example-5.0.0.Alpha1-sources.jar文件,提供了比较丰富的example例子,多看几遍还是非常有收获的,这里记录下. 先来看下channelHandler的两个不同继承: 方式一:直接从ChannelHandlerAdapter类里继承,读取操作从channelRead方法里执行 @Sharable publ

caffe 学习记录1

1 ubuntu git clone 默认在当前文件夹 2 caffe 基础了解:https://www.zhihu.com/question/27982282/answer/39350629 3 当然,官网才是大牛:http://caffe.berkeleyvision.org/ 4 Caffe支持三种数据格式输入网络,包括Image(.jpg, .png等),leveldb,lmdb,根据自己需要选择不同输入吧. 5 深度学习结构剖析(错误纠正,(2)代表一个滤波器多个参数<->一个滤波器

Mybatis学习记录(二)--Mybatis开发DAO方式

mybatis开发dao的方法通常用两种,一种是传统DAO的方法,一种是基于mapper代理的方法,下面学习这两种开发模式. 写dao之前应该要对SqlSession有一个更加细致的了解 一.mybatis的SqlSession使用范围 SqlSessionFactoryBuilder用于创建SqlSessionFacoty,SqlSessionFacoty一旦创建完成就不需要SqlSessionFactoryBuilder了,因为SqlSession是通过SqlSessionFactory生产

Spring学习记录(二)---容器和属性配置

下载spring包,在eclipse搭建spring环境. 这步我在eclipse中无法导入包,看网上的: http://sishuok.(和谐)com/forum/blogPost/list/2428.html 建一个java project 三个java文件,一个xml文件 1 package com.guigu.spring.beans; 2 3 public class HelloWord { 4 private String name; 5 public String getName(

Tornado学习记录二

Coroutines Coroutines are the recommended way to write asynchronous code in Tornado. Coroutines use the Python yield keyword to suspend and resume execution instead of a chain of callbacks (cooperative lightweight threads as seen in frameworks like g

caffe学习记录2——blobs

参考:caffe官网  2016-01-23 10:08:22 1 blobs,layers,nets是caffe模型的骨架 2 blobs是作者写好的数据存储的“容器”,可以有效实现CPU和GPU之间的同步(隐藏了这些复杂的操作),搬移,传递等.它提供了统一的接口,可以存储数据,如batches of images, model parameters, and derivatives for optimization等. 3 blobs最后一层改变最快.若blobs为(n, k, h, w),