-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathInnerProductLayer.cpp
More file actions
50 lines (42 loc) · 1.12 KB
/
Copy pathInnerProductLayer.cpp
File metadata and controls
50 lines (42 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
* @Author: Weiliang Chen
* @Date: 2016-09-29 10:51:07
* @Last Modified by: Weiliang Chen
* @Last Modified time: 2016-09-29 10:55:27
*/
#include "InnerProductLayer.h"
#include "common.h"
#include "Utils.h"
namespace fn {
template<typename Dtype>
InnerProductLayer<Dtype>::InnerProductLayer()
{
}
template<typename Dtype>
InnerProductLayer<Dtype>::~InnerProductLayer()
{
}
template<typename Dtype>
void InnerProductLayer<Dtype>::LayerSetUp(const arma::Mat<Dtype>& weights, const arma::Col<Dtype>& bias)
{
weights_ = weights;
bias_ = bias;
}
template<typename Dtype>
void InnerProductLayer<Dtype>::Forward(const arma::Cube<Dtype>& bottom, arma::Col<Dtype>& top)
{
arma::Mat<Dtype> feat_mat;
im2col(bottom, bottom.n_rows, bottom.n_cols, 0, 0, 1, 1, feat_mat);
arma::Mat<Dtype>result = feat_mat * weights_;
for (int i = 0; i < result.n_elem; ++i) {
top.at(i) = result.at(i);
}
top += bias_;
}
template<typename Dtype>
void InnerProductLayer<Dtype>::CalShape(const arma::Cube<Dtype>& bottom, std::vector<int>& shape)
{
NOT_IMPLEMENTED
}
INSTANTIATE_CLASS(InnerProductLayer);
}