zoukankan      html  css  js  c++  java
  • 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),即寻址时,地址加1是最后一维n加1.

    5 Number / N is the batch size of the data和Channel / K is the feature dimension

    6 使用blobs中通常存储data and diff ,前者是数据的值,后者是梯度值。进一步地,可以存在cpu中,也可以存在GPU中,访问有两种方式:

    1 const Dtype* cpu_data() const;
    2 Dtype* mutable_cpu_data(); 

    (similarly for gpu and diff).

    7 在GPU模式中,按照cpu模式将数据拷贝到blobs中,然后调用设备核去进行GPU计算,并将数据运到高层。只要所有层都配置了GPU模式,中间的计算过程的数据都保留在GPU中。判断Blobs是否拷贝了数据:

     1 // Assuming that data are on the CPU initially, and we have a blob.
     2 const Dtype* foo;
     3 Dtype* bar;
     4 foo = blob.gpu_data(); // data copied cpu->gpu.
     5 foo = blob.cpu_data(); // no data copied since both have up-to-date contents.
     6 bar = blob.mutable_gpu_data(); // no data copied.
     7 // ... some operations ...
     8 bar = blob.mutable_gpu_data(); // no data copied when we are still on GPU.
     9 foo = blob.cpu_data(); // data copied gpu->cpu, since the gpu side has modified the data
    10 foo = blob.gpu_data(); // no data copied since both have up-to-date contents
    11 bar = blob.mutable_cpu_data(); // still no data copied.
    12 bar = blob.mutable_gpu_data(); // data copied cpu->gpu.
    13 bar = blob.mutable_cpu_data(); // data copied gpu->cpu.
  • 相关阅读:
    javascript 数字时钟
    ubuntu下键盘背景灯光设置
    使用百度地图SDK
    ListView 的Item状态改变和保存
    继续Jsoup 正方教务系统的教学质量评价一键好评
    Java下的可视化开发工具使用 WindowBuilder Pro
    js 数组排序
    js数组去重
    js call() apply()
    [总结] js的2种继承方式详解
  • 原文地址:https://www.cnblogs.com/Wanggcong/p/5153257.html
Copyright © 2011-2022 走看看