]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - jacinto-ai/caffe-jacinto.git/blob - src/caffe/test/test_net_proto.cpp
net
[jacinto-ai/caffe-jacinto.git] / src / caffe / test / test_net_proto.cpp
1 // Copyright 2013 Yangqing Jia
3 #include <cstring>
4 #include <cuda_runtime.h>
5 #include <google/protobuf/text_format.h>
6 #include <gtest/gtest.h>
8 #include "caffe/blob.hpp"
9 #include "caffe/common.hpp"
10 #include "caffe/net.hpp"
11 #include "caffe/proto/caffe.pb.h"
13 #include "caffe/test/lenet.hpp"
14 #include "caffe/test/test_caffe_main.hpp"
16 namespace caffe {
18 template <typename Dtype>
19 class NetProtoTest : public ::testing::Test {};
21 typedef ::testing::Types<float, double> Dtypes;
22 TYPED_TEST_CASE(NetProtoTest, Dtypes);
24 TYPED_TEST(NetProtoTest, TestSetup) {
25   NetParameter net_param;
26   string lenet_string(kLENET);
27   // Load the network
28   CHECK(google::protobuf::TextFormat::ParseFromString(
29       lenet_string, &net_param));
30   // check if things are right
31   EXPECT_EQ(net_param.layers_size(), 9);
32   EXPECT_EQ(net_param.bottom_size(), 2);
33   EXPECT_EQ(net_param.top_size(), 0);
35   // Now, initialize a network using the parameter
36   shared_ptr<Blob<TypeParam> > data(new Blob<TypeParam>(10, 1, 28, 28));
37   shared_ptr<Blob<TypeParam> > label(new Blob<TypeParam>(10, 1, 1, 1));
38   vector<Blob<TypeParam>*> bottom_vec;
39   bottom_vec.push_back(data.get());
40   bottom_vec.push_back(label.get());
42   Net<TypeParam> caffe_net(net_param, bottom_vec);
43   EXPECT_EQ(caffe_net.layer_names().size(), 9);
44   EXPECT_EQ(caffe_net.blob_names().size(), 10);
46   for (int i = 0; i < caffe_net.blobs().size(); ++i) {
47     LOG(ERROR) << "Blob: " << caffe_net.blob_names()[i];
48     LOG(ERROR) << "size: " << caffe_net.blobs()[i]->num() << ", "
49         << caffe_net.blobs()[i]->channels() << ", "
50         << caffe_net.blobs()[i]->height() << ", "
51         << caffe_net.blobs()[i]->width();
52   }
53 }
55 }  // namespace caffe