SINGA-21 Code review - 2

Fix a bug caused by gflags version by adding a macro at main.cc to redefine the 
namespace gflags=google
Update mnist/cifar10 example by adding a Makefile.example


Project: http://git-wip-us.apache.org/repos/asf/incubator-singa/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-singa/commit/cfde4718
Tree: http://git-wip-us.apache.org/repos/asf/incubator-singa/tree/cfde4718
Diff: http://git-wip-us.apache.org/repos/asf/incubator-singa/diff/cfde4718

Branch: refs/heads/master
Commit: cfde4718ad2e5544257056200003830568fb488c
Parents: acfc409
Author: wang wei <[email protected]>
Authored: Wed Jun 24 16:35:23 2015 +0800
Committer: wang wei <[email protected]>
Committed: Wed Jun 24 17:11:38 2015 +0800

----------------------------------------------------------------------
 examples/cifar10/Makefile         |  20 ---
 examples/cifar10/Makefile.example |  20 +++
 examples/cifar10/model.conf       |   2 +-
 examples/mnist/mlp.conf           | 224 ---------------------------------
 examples/mnist/model.conf         | 224 +++++++++++++++++++++++++++++++++
 src/main.cc                       |   4 +-
 6 files changed, 248 insertions(+), 246 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/cfde4718/examples/cifar10/Makefile
----------------------------------------------------------------------
diff --git a/examples/cifar10/Makefile b/examples/cifar10/Makefile
deleted file mode 100644
index 2a8b67a..0000000
--- a/examples/cifar10/Makefile
+++ /dev/null
@@ -1,20 +0,0 @@
-libs :=singa glog protobuf
-
-.PHONY: all download create
-
-download: cifar-10-binary-bin
-
-cifar-10-binary-bin:
-       wget http://www.cs.toronto.edu/~kriz/cifar-10-binary.tar.gz
-       tar xf cifar-10-binary.tar.gz
-
-create:
-       $(CXX) create_shard.cc -std=c++11 -lsingashard -lprotobuf -lglog 
-I../../include \
-               -L../../.libs/ -Wl,-unresolved-symbols=ignore-in-shared-libs 
-Wl,-rpath=../../.libs/ \
-               -o create_shard.bin
-       mkdir cifar10_train_shard
-       mkdir cifar10_test_shard
-       ./create_shard.bin cifar-10-batches-bin .
-
-
-

http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/cfde4718/examples/cifar10/Makefile.example
----------------------------------------------------------------------
diff --git a/examples/cifar10/Makefile.example 
b/examples/cifar10/Makefile.example
new file mode 100644
index 0000000..2a8b67a
--- /dev/null
+++ b/examples/cifar10/Makefile.example
@@ -0,0 +1,20 @@
+libs :=singa glog protobuf
+
+.PHONY: all download create
+
+download: cifar-10-binary-bin
+
+cifar-10-binary-bin:
+       wget http://www.cs.toronto.edu/~kriz/cifar-10-binary.tar.gz
+       tar xf cifar-10-binary.tar.gz
+
+create:
+       $(CXX) create_shard.cc -std=c++11 -lsingashard -lprotobuf -lglog 
-I../../include \
+               -L../../.libs/ -Wl,-unresolved-symbols=ignore-in-shared-libs 
-Wl,-rpath=../../.libs/ \
+               -o create_shard.bin
+       mkdir cifar10_train_shard
+       mkdir cifar10_test_shard
+       ./create_shard.bin cifar-10-batches-bin .
+
+
+

http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/cfde4718/examples/cifar10/model.conf
----------------------------------------------------------------------
diff --git a/examples/cifar10/model.conf b/examples/cifar10/model.conf
index 0d6e4fd..42be6dd 100644
--- a/examples/cifar10/model.conf
+++ b/examples/cifar10/model.conf
@@ -1,6 +1,6 @@
 name: "cifar10-convnet"
 train_steps: 1000
-test_steps:10
+test_steps:100
 test_frequency:300
 display_frequency:30
 alg: kBackPropagation

http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/cfde4718/examples/mnist/mlp.conf
----------------------------------------------------------------------
diff --git a/examples/mnist/mlp.conf b/examples/mnist/mlp.conf
deleted file mode 100644
index 3786c4f..0000000
--- a/examples/mnist/mlp.conf
+++ /dev/null
@@ -1,224 +0,0 @@
-name: "deep-big-simple-mlp"
-train_steps: 10000
-test_steps:10
-test_frequency:60
-display_frequency:30
-alg: kBackPropagation
-updater{
-  base_lr: 0.001
-  lr_change: kStep
-  type: kSGD
-  step_conf{
-    change_freq: 60
-    gamma: 0.997
-  }
-}
-
-neuralnet {
-layer {
-  name: "data"
-  type: kShardData
-  sharddata_conf {
-    path: "examples/mnist/mnist_train_shard"
-    batchsize: 1000
-  }
-  exclude: kTest
-}
-
-layer {
-  name: "data"
-  type: kShardData
-  sharddata_conf {
-    path: "examples/mnist/mnist_test_shard"
-    batchsize: 1000
-  }
-  exclude: kTrain
-}
-
-layer{
-  name:"mnist"
-  type: kMnist
-  srclayers: "data"
-  mnist_conf {
-#    sigma: 6
-#    alpha: 38
-#    gamma: 15
-#    kernel: 21
-#    elastic_freq:100
-#    beta:15
-#    resize: 29
-    norm_a: 127.5
-    norm_b: 1
-  }
-}
-
-
-layer{
-  name: "label"
-  type: kLabel
-  srclayers: "data"
-}
-
-layer{
-  name: "fc1"
-  type: kInnerProduct
-  srclayers:"mnist"
-  innerproduct_conf{
-    num_output: 2500
-  }
-  param{
-    name: "weight"
-    init_method: kUniform
-    low:-0.05
-    high:0.05
-  }
-  param{
-    name: "bias"
-    init_method: kUniform
-    low: -0.05
-    high:0.05
-  }
-}
-
-layer{
-  name: "tanh1"
-  type: kTanh
-  srclayers:"fc1"
-}
-layer{
-  name: "fc2"
-  type: kInnerProduct
-  srclayers:"tanh1"
-  innerproduct_conf{
-    num_output: 2000
-  }
-  param{
-    name: "weight"
-    init_method: kUniform
-    low:-0.05
-    high:0.05
-  }
-  param{
-    name: "bias"
-    init_method: kUniform
-    low: -0.05
-    high:0.05
-  }
-}
-
-layer{
-  name: "tanh2"
-  type: kTanh
-  srclayers:"fc2"
-}
-layer{
-  name: "fc3"
-  type:  kInnerProduct
-  srclayers:"tanh2"
-  innerproduct_conf{
-    num_output: 1500
-  }
-  param{
-    name: "weight"
-    init_method: kUniform
-    low:-0.05
-    high:0.05
-  }
-  param{
-    name: "bias"
-    init_method: kUniform
-    low: -0.05
-    high:0.05
-  }
-
-}
-
-layer{
-  name: "tanh3"
-  type: kTanh
-  srclayers:"fc3"
-}
-layer{
-  name: "fc4"
-  type: kInnerProduct
-  srclayers:"tanh3"
-  innerproduct_conf{
-    num_output: 1000
-  }
-  param{
-    name: "weight"
-    init_method: kUniform
-    low:-0.05
-    high:0.05
-  }
-  param{
-    name: "bias"
-    init_method: kUniform
-    low: -0.05
-    high:0.05
-  }
-
-}
-
-layer{
-  name: "tanh4"
-  type: kTanh
-  srclayers:"fc4"
-}
-layer{
-  name: "fc5"
-  type: kInnerProduct
-  srclayers:"tanh4"
-  innerproduct_conf{
-    num_output: 500
-  }
-  param{
-    name: "weight"
-    init_method: kUniform
-    low:-0.05
-    high:0.05
-  }
-  param{
-    name: "bias"
-    init_method: kUniform
-    low: -0.05
-    high:0.05
-  }
-
-}
-
-layer{
-  name: "tanh5"
-  type: kTanh
-  srclayers:"fc5"
-}
-layer{
-  name: "fc6"
-  type: kInnerProduct
-  srclayers:"tanh5"
-  innerproduct_conf{
-    num_output: 10
-  }
-  param{
-    name: "weight"
-    init_method: kUniform
-    low:-0.05
-    high:0.05
-  }
-  param{
-    name: "bias"
-    init_method: kUniform
-    low: -0.05
-    high:0.05
-  }
-}
-layer{
-  name: "loss"
-  type:kSoftmaxLoss
-  softmaxloss_conf{
-    topk:1
-  }
-  srclayers:"fc6"
-  srclayers:"label"
-}
-}

http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/cfde4718/examples/mnist/model.conf
----------------------------------------------------------------------
diff --git a/examples/mnist/model.conf b/examples/mnist/model.conf
new file mode 100644
index 0000000..3786c4f
--- /dev/null
+++ b/examples/mnist/model.conf
@@ -0,0 +1,224 @@
+name: "deep-big-simple-mlp"
+train_steps: 10000
+test_steps:10
+test_frequency:60
+display_frequency:30
+alg: kBackPropagation
+updater{
+  base_lr: 0.001
+  lr_change: kStep
+  type: kSGD
+  step_conf{
+    change_freq: 60
+    gamma: 0.997
+  }
+}
+
+neuralnet {
+layer {
+  name: "data"
+  type: kShardData
+  sharddata_conf {
+    path: "examples/mnist/mnist_train_shard"
+    batchsize: 1000
+  }
+  exclude: kTest
+}
+
+layer {
+  name: "data"
+  type: kShardData
+  sharddata_conf {
+    path: "examples/mnist/mnist_test_shard"
+    batchsize: 1000
+  }
+  exclude: kTrain
+}
+
+layer{
+  name:"mnist"
+  type: kMnist
+  srclayers: "data"
+  mnist_conf {
+#    sigma: 6
+#    alpha: 38
+#    gamma: 15
+#    kernel: 21
+#    elastic_freq:100
+#    beta:15
+#    resize: 29
+    norm_a: 127.5
+    norm_b: 1
+  }
+}
+
+
+layer{
+  name: "label"
+  type: kLabel
+  srclayers: "data"
+}
+
+layer{
+  name: "fc1"
+  type: kInnerProduct
+  srclayers:"mnist"
+  innerproduct_conf{
+    num_output: 2500
+  }
+  param{
+    name: "weight"
+    init_method: kUniform
+    low:-0.05
+    high:0.05
+  }
+  param{
+    name: "bias"
+    init_method: kUniform
+    low: -0.05
+    high:0.05
+  }
+}
+
+layer{
+  name: "tanh1"
+  type: kTanh
+  srclayers:"fc1"
+}
+layer{
+  name: "fc2"
+  type: kInnerProduct
+  srclayers:"tanh1"
+  innerproduct_conf{
+    num_output: 2000
+  }
+  param{
+    name: "weight"
+    init_method: kUniform
+    low:-0.05
+    high:0.05
+  }
+  param{
+    name: "bias"
+    init_method: kUniform
+    low: -0.05
+    high:0.05
+  }
+}
+
+layer{
+  name: "tanh2"
+  type: kTanh
+  srclayers:"fc2"
+}
+layer{
+  name: "fc3"
+  type:  kInnerProduct
+  srclayers:"tanh2"
+  innerproduct_conf{
+    num_output: 1500
+  }
+  param{
+    name: "weight"
+    init_method: kUniform
+    low:-0.05
+    high:0.05
+  }
+  param{
+    name: "bias"
+    init_method: kUniform
+    low: -0.05
+    high:0.05
+  }
+
+}
+
+layer{
+  name: "tanh3"
+  type: kTanh
+  srclayers:"fc3"
+}
+layer{
+  name: "fc4"
+  type: kInnerProduct
+  srclayers:"tanh3"
+  innerproduct_conf{
+    num_output: 1000
+  }
+  param{
+    name: "weight"
+    init_method: kUniform
+    low:-0.05
+    high:0.05
+  }
+  param{
+    name: "bias"
+    init_method: kUniform
+    low: -0.05
+    high:0.05
+  }
+
+}
+
+layer{
+  name: "tanh4"
+  type: kTanh
+  srclayers:"fc4"
+}
+layer{
+  name: "fc5"
+  type: kInnerProduct
+  srclayers:"tanh4"
+  innerproduct_conf{
+    num_output: 500
+  }
+  param{
+    name: "weight"
+    init_method: kUniform
+    low:-0.05
+    high:0.05
+  }
+  param{
+    name: "bias"
+    init_method: kUniform
+    low: -0.05
+    high:0.05
+  }
+
+}
+
+layer{
+  name: "tanh5"
+  type: kTanh
+  srclayers:"fc5"
+}
+layer{
+  name: "fc6"
+  type: kInnerProduct
+  srclayers:"tanh5"
+  innerproduct_conf{
+    num_output: 10
+  }
+  param{
+    name: "weight"
+    init_method: kUniform
+    low:-0.05
+    high:0.05
+  }
+  param{
+    name: "bias"
+    init_method: kUniform
+    low: -0.05
+    high:0.05
+  }
+}
+layer{
+  name: "loss"
+  type:kSoftmaxLoss
+  softmaxloss_conf{
+    topk:1
+  }
+  srclayers:"fc6"
+  srclayers:"label"
+}
+}

http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/cfde4718/src/main.cc
----------------------------------------------------------------------
diff --git a/src/main.cc b/src/main.cc
index 89306d8..77898be 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -1,7 +1,9 @@
 #include <gflags/gflags.h>
 #include <glog/logging.h>
 #include "trainer/trainer.h"
-
+#ifndef GFLAGS_GFLAGS_H_
+  namespace gflags = google;
+#endif  // GFLAGS_GFLAGS_H_
 /**
  * \file main.cc is the main entry of SINGA, like the driver program for 
Hadoop.
  *

Reply via email to