#include <algorithm>
#include <vector>
#include "caffe/layers/leaky_layer.hpp"
namespace caffe {
template <typename Dtype>
void LEAKYLayer<Dtype>::Forward_cpu(const vector<Blob<Dtype>*>& bottom,
const vector<Blob<Dtype>*>& top) {
const Dtype* bottom_data = bottom[0]->cpu_data();
Dtype* top_data = top[0]->mutable_cpu_data();
const int count = bottom[0]->count();
Dtype leaky_scale = this->layer_param_.leaky_param().leaky_scale();
for (int i = 0; i < count; ++i) {
top_data[i] = bottom_data[i] > 0 ? bottom_data[i] : leaky_scale*bottom_data[i];
}
}
template <typename Dtype>
void LEAKYLayer<Dtype>::Backward_cpu(const vector<Blob<Dtype>*>& top,
const vector<bool>& propagate_down,
const vector<Blob<Dtype>*>& bottom) {
if (propagate_down[0]) {
const Dtype* bottom_data = bottom[0]->cpu_data();
const Dtype* top_diff = top[0]->cpu_diff();
Dtype* bottom_diff = bottom[0]->mutable_cpu_diff();
const int count = bottom[0]->count();
Dtype leaky_scale = this->layer_param_.leaky_param().leaky_scale();
for (int i = 0; i < count; ++i) {
bottom_diff[i] = bottom_data[i] > 0 ? top_diff[i] : top_diff[i] * leaky_scale;
}
}
}
#ifdef CPU_ONLY
STUB_GPU(LEAKYLayer);
#endif
INSTANTIATE_CLASS(LEAKYLayer);
} // namespace caffe
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
在caffe下实现yolo需要添加一些特殊的层,其中yolo使用的激活函数为leaky,即需要在caffe特定目录下添加该层的源码实现。 (1)leaky_layer.hpp放在caffe/include/caffe/layers下; (2)leaky_layer.cpp放在caffe/src/caffe/layers下; (3)修改caffe/src/caffe/proto下的caffe.proto文件
资源推荐
资源详情
资源评论






























收起资源包目录




共 2 条
- 1
资源评论


零尾
- 粉丝: 1465
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助


最新资源
- 计算机基础专升本投影讲稿.doc
- 计算机应用基础.ppt
- 大数据在街道设计中的应用探索.docx
- 基于灰色神经网络的剩余电流预测研究.docx
- 计算机等级考试Vfp笔试题.doc
- 计算机教师招聘试题.doc
- 在Authorware多媒体制作课程教学中四步法的应用精品文档.doc
- 《数据库技术与应用》第6章习题答案.docx
- 电子信息工程和通信工程专业.doc
- 机械制造与自动化专业大学生职业生涯规划书.doc
- 基于大数据的精准推送分类信息发布平台.docx
- C课程设计(凌世林组)通信录管理程序.doc
- 柔性项目管理信息系统的设计与实现.doc
- 网络环境下提高大学生写作能力的模式探讨-大学英语.docx
- 中职学校翻转课堂信息化互动教学模式探究.docx
- 宁波第二外贸电子商务论坛.doc
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈



安全验证
文档复制为VIP权益,开通VIP直接复制
