-
Notifications
You must be signed in to change notification settings - Fork 2
/
Blob.h
60 lines (48 loc) · 1.39 KB
/
Blob.h
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
51
52
53
54
55
56
57
58
59
60
/*
* @Author: Weiliang Chen
* @Date: 2016-09-29 10:51:07
* @Last Modified by: Weiliang Chen
* @Last Modified time: 2016-09-29 10:54:27
*/
#ifndef FN_BLOB_H_
#define FN_BLOB_H_
#include <string>
#include <vector>
#include <armadillo>
#include "common.h"
namespace fn{
template <typename Dtype>
class Blob
{
public:
Blob() {};
explicit Blob(const std::vector<int>& shape);
explicit Blob(const int height, const int width, const int channels, const int num);
/**
* [Change the dimensions of the blob ]
* @Author Weiliang Chen
* @DateTime 2016-09-25T11:41:50+0800
* @param shape [description]
*/
void reshape(const std::vector<int>& shape);
inline std::string shape_string() const {
std::ostringstream stream;
for (int i = 0; i < shape_.size(); ++i) {
stream << shape_[i] << " ";
}
stream << "(" << count_ << ")";
return stream.str();
}
inline const std::vector<int>& shape() const { return shape_; }
inline int num_axes() const { return shape_.size(); }
inline std::vector<arma::Cube<Dtype>> * data_vec() { return &data_; }
~Blob();
private:
std::vector<arma::Cube<Dtype>> data_;
// width,height,channels,number
std::vector<int> shape_;
int count_;
//DISABLE_COPY_AND_ASSIGN(Blob);
}; // class Blob
} // namespace fn
#endif // !FN_BLOB_H_