-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmain.cpp
More file actions
43 lines (37 loc) · 1.11 KB
/
main.cpp
File metadata and controls
43 lines (37 loc) · 1.11 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
#include <stdio.h>
#include "caffe/caffe.hpp"
#include "caffe/util/io.hpp"
#include "caffe/blob.hpp"
#include "caffe/common.hpp"
#include "caffe/filler.hpp"
using namespace caffe;
using namespace std;
typedef double Dtype;
int main(int argc, char** argv) {
Blob<Dtype>* const blob = new Blob<Dtype>(20, 30, 40, 50);
if(blob){
cout<<"Size of blob:";
cout<<" N="<<blob->num();
cout<<" K="<<blob->channels();
cout<<" H="<<blob->height();
cout<<" W="<<blob->width();
cout<<" C="<<blob->count();
cout<<endl;
}
// Random sampling from uniform distribution
FillerParameter filler_param;
filler_param.set_min(-3);
filler_param.set_max(3);
UniformFiller<Dtype> filler(filler_param);
filler.Fill(blob);
// absolute sum of blob
Dtype expected_asum = 0;
const Dtype* data = blob->cpu_data();
for (int i = 0; i < blob->count(); ++i) {
expected_asum += fabs(data[i]);
}
cout<<"expected asum of blob: "<<expected_asum<<endl;
cout<<"asum of blob on cpu: "<<blob->asum_data()<<endl;
delete blob;
return 0;
}