singa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wang...@apache.org
Subject [2/3] incubator-singa git commit: SINGA-232 Alexnet on Imagenet
Date Wed, 10 Aug 2016 06:01:57 GMT
SINGA-232 Alexnet on Imagenet

Replace CudnnDropout with Dropout
Add argument "-h"


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

Branch: refs/heads/dev
Commit: 8051720fd9cc64854ba8f26a6758b9c9d7d6ce59
Parents: 34d3ae6
Author: Xiangrui <caixr91@gmail.com>
Authored: Tue Aug 9 21:04:24 2016 +0800
Committer: Xiangrui <caixr91@gmail.com>
Committed: Tue Aug 9 21:04:24 2016 +0800

----------------------------------------------------------------------
 examples/imagenet/alexnet.cc  | 14 +++++++-------
 examples/imagenet/ilsvrc12.cc |  5 +++--
 2 files changed, 10 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/8051720f/examples/imagenet/alexnet.cc
----------------------------------------------------------------------
diff --git a/examples/imagenet/alexnet.cc b/examples/imagenet/alexnet.cc
index 22cc88f..270312c 100644
--- a/examples/imagenet/alexnet.cc
+++ b/examples/imagenet/alexnet.cc
@@ -24,7 +24,7 @@
 #include <cmath>
 #include "../../src/model/layer/cudnn_activation.h"
 #include "../../src/model/layer/cudnn_convolution.h"
-#include "../../src/model/layer/cudnn_dropout.h"
+#include "../../src/model/layer/dropout.h"
 #include "../../src/model/layer/cudnn_lrn.h"
 #include "../../src/model/layer/cudnn_pooling.h"
 #include "../../src/model/layer/dense.h"
@@ -133,7 +133,7 @@ LayerConf GenFlattenConf(string name) {
 LayerConf GenDropoutConf(string name, float dropout_ratio) {
   LayerConf conf;
   conf.set_name(name);
-  conf.set_type("CudnnDropout");
+  conf.set_type("Dropout");
   DropoutConf *dropout = conf.mutable_dropout_conf();
   dropout->set_dropout_ratio(dropout_ratio);
   return conf;
@@ -164,10 +164,10 @@ FeedForwardNet CreateNet() {
   net.Add(new Flatten(), GenFlattenConf("flat"));
   net.Add(new Dense(), GenDenseConf("ip6", 4096, 0.005, 1, 1.0));
   net.Add(new CudnnActivation(), GenReLUConf("relu6"));
-  net.Add(new CudnnDropout(), GenDropoutConf("drop6", 0.5));
+  net.Add(new Dropout(), GenDropoutConf("drop6", 0.5));
   net.Add(new Dense(), GenDenseConf("ip7", 4096, 0.005, 1, 1.0));
   net.Add(new CudnnActivation(), GenReLUConf("relu7"));
-  net.Add(new CudnnDropout(), GenDropoutConf("drop7", 0.5));
+  net.Add(new Dropout(), GenDropoutConf("drop7", 0.5));
   net.Add(new Dense(), GenDenseConf("ip8", 1000, 0.01, 1));
 
   return net;
@@ -348,8 +348,8 @@ void Train(int num_epoch, float lr, size_t batchsize, size_t train_file_size,
 
 int main(int argc, char **argv) {
   singa::InitChannel(nullptr);
-
-  if (argc == 1) {
+  int pos = singa::ArgPos(argc, argv, "-h");
+  if (pos != -1) {
     std::cout << "Usage:\n"
               << "\t-epoch <int>: number of epoch to be trained, default is 90;\n"
               << "\t-lr <float>: base learning rate;\n"
@@ -366,7 +366,7 @@ int main(int argc, char **argv) {
                  "feed to the model.\n";
     return 0;
   }
-  int pos = singa::ArgPos(argc, argv, "-epoch");
+  pos = singa::ArgPos(argc, argv, "-epoch");
   int nEpoch = 90;
   if (pos != -1) nEpoch = atoi(argv[pos + 1]);
 

http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/8051720f/examples/imagenet/ilsvrc12.cc
----------------------------------------------------------------------
diff --git a/examples/imagenet/ilsvrc12.cc b/examples/imagenet/ilsvrc12.cc
index 2bc07f2..c9e6d2f 100644
--- a/examples/imagenet/ilsvrc12.cc
+++ b/examples/imagenet/ilsvrc12.cc
@@ -24,7 +24,8 @@
 #include "singa/utils/channel.h"
 #include "singa/utils/string.h"
 int main(int argc, char **argv) {
-  if (argc == 1) {
+  int pos = singa::ArgPos(argc, argv, "-h");
+  if (pos != -1) {
     std::cout << "Usage:\n"
               << "\t-trainlist <file>: the file of training list;\n"
               << "\t-trainfolder <folder>: the folder of training images;\n"
@@ -35,7 +36,7 @@ int main(int argc, char **argv) {
                  "each binary file.\n";
     return 0;
   }
-  int pos = singa::ArgPos(argc, argv, "-trainlist");
+  pos = singa::ArgPos(argc, argv, "-trainlist");
   string train_image_list = "imagenet/label/train.txt";
   if (pos != -1) train_image_list = argv[pos + 1];
 


Mime
View raw message