move model's pad layer into conv layer; add script to create db and train net by...
authorchyojn <chyojn@gmail.com>
Sat, 1 Mar 2014 03:21:13 +0000 (11:21 +0800)
committerchyojn <chyojn@gmail.com>
Sat, 1 Mar 2014 03:24:16 +0000 (11:24 +0800)
12 files changed:
examples/cifar/cifar10_18pct_solver.prototxt
examples/cifar/cifar10_18pct_solver_lr1.prototxt [new file with mode: 0644]
examples/cifar/cifar10_18pct_solver_lr2.prototxt [new file with mode: 0644]
examples/cifar/cifar10_18pct_test.prototxt
examples/cifar/cifar10_18pct_train.prototxt [moved from examples/cifar/cifar10_18pct.prototxt with 82% similarity]
examples/cifar/cifar10_80sec_solver.prototxt
examples/cifar/cifar10_80sec_solver_lr1.prototxt [new file with mode: 0644]
examples/cifar/cifar10_80sec_test.prototxt
examples/cifar/cifar10_80sec_train.prototxt [moved from examples/cifar/cifar10_80sec.prototxt with 82% similarity]
examples/cifar/create_cifar10.sh [new file with mode: 0755]
examples/cifar/train_18pct.sh [new file with mode: 0755]
examples/cifar/train_80sec.sh [new file with mode: 0755]

index d8f9a39..b068c4e 100644 (file)
@@ -2,27 +2,27 @@
 # then another factor of 10 after 10 more epochs (5000 iters)
 
 # The training protocol buffer definition
-train_net: "cifar10_18pct.prototxt"
+train_net: "cifar10_18pct_train.prototxt"
 # The testing protocol buffer definition
 test_net: "cifar10_18pct_test.prototxt"
 # test_iter specifies how many forward passes the test should carry out.
-# In the case of MNIST, we have test batch size 100 and 100 test iterations,
+# In the case of CIFAR10, we have test batch size 100 and 100 test iterations,
 # covering the full 10,000 testing images.
 test_iter: 100
-# Carry out testing every 500 training iterations.
-test_interval: 500
+# Carry out testing every 1000 training iterations.
+test_interval: 1000
 # The base learning rate, momentum and the weight decay of the network.
 base_lr: 0.001
 momentum: 0.9
 weight_decay: 0.004
 # The learning rate policy
 lr_policy: "fixed"
-# Display every 100 iterations
-display: 100
+# Display every 200 iterations
+display: 200
 # The maximum number of iterations
-max_iter: 100000
+max_iter: 60000
 # snapshot intermediate results
-snapshot: 5000
+snapshot: 10000
 snapshot_prefix: "cifar10_18pct"
 # solver mode: 0 for CPU and 1 for GPU
 solver_mode: 1
diff --git a/examples/cifar/cifar10_18pct_solver_lr1.prototxt b/examples/cifar/cifar10_18pct_solver_lr1.prototxt
new file mode 100644 (file)
index 0000000..1cbd4ab
--- /dev/null
@@ -0,0 +1,30 @@
+# reduce learning rate after 120 epochs (60000 iters) by factor 0f 10
+# then another factor of 10 after 10 more epochs (5000 iters)
+
+# The training protocol buffer definition
+train_net: "cifar10_18pct_train.prototxt"
+# The testing protocol buffer definition
+test_net: "cifar10_18pct_test.prototxt"
+# test_iter specifies how many forward passes the test should carry out.
+# In the case of CIFAR10, we have test batch size 100 and 100 test iterations,
+# covering the full 10,000 testing images.
+test_iter: 100
+# Carry out testing every 1000 training iterations.
+test_interval: 1000
+# The base learning rate, momentum and the weight decay of the network.
+base_lr: 0.0001
+momentum: 0.9
+weight_decay: 0.004
+# The learning rate policy
+lr_policy: "fixed"
+# Display every 200 iterations
+display: 200
+# The maximum number of iterations
+max_iter: 65000
+# snapshot intermediate results
+snapshot: 5000
+snapshot_prefix: "cifar10_18pct"
+# solver mode: 0 for CPU and 1 for GPU
+solver_mode: 1
+
+device_id: 0
diff --git a/examples/cifar/cifar10_18pct_solver_lr2.prototxt b/examples/cifar/cifar10_18pct_solver_lr2.prototxt
new file mode 100644 (file)
index 0000000..5730566
--- /dev/null
@@ -0,0 +1,30 @@
+# reduce learning rate after 120 epochs (60000 iters) by factor 0f 10
+# then another factor of 10 after 10 more epochs (5000 iters)
+
+# The training protocol buffer definition
+train_net: "cifar10_18pct_train.prototxt"
+# The testing protocol buffer definition
+test_net: "cifar10_18pct_test.prototxt"
+# test_iter specifies how many forward passes the test should carry out.
+# In the case of CIFAR10, we have test batch size 100 and 100 test iterations,
+# covering the full 10,000 testing images.
+test_iter: 100
+# Carry out testing every 1000 training iterations.
+test_interval: 1000
+# The base learning rate, momentum and the weight decay of the network.
+base_lr: 0.00001
+momentum: 0.9
+weight_decay: 0.004
+# The learning rate policy
+lr_policy: "fixed"
+# Display every 200 iterations
+display: 200
+# The maximum number of iterations
+max_iter: 70000
+# snapshot intermediate results
+snapshot: 5000
+snapshot_prefix: "cifar10_18pct"
+# solver mode: 0 for CPU and 1 for GPU
+solver_mode: 1
+
+device_id: 0
index c28d4e6..8b6c0ff 100644 (file)
@@ -3,7 +3,7 @@ layers {
  layer {\r
    name: "cifar"\r
    type: "data"\r
-   source: "cifar10_db/cifar-test-leveldb"\r
+   source: "cifar10-leveldb/cifar-test-leveldb"\r
    meanfile: "mean.binaryproto"\r
    batchsize: 100\r
  }\r
@@ -13,19 +13,11 @@ layers {
 # ------------------------ layer 1 -----------------------------\r
 layers {\r
  layer {\r
-   name: "pad1"\r
-   type: "padding"\r
-   pad: 2\r
- }\r
- bottom: "data"\r
- top: "pad1"\r
-}\r
-layers {\r
- layer {\r
    name: "conv1"\r
    type: "conv"\r
    num_output: 32\r
    kernelsize: 5\r
+   pad: 2\r
    stride: 1\r
    weight_filler {\r
      type: "gaussian"\r
@@ -37,7 +29,7 @@ layers {
    blobs_lr: 1.\r
    blobs_lr: 2.\r
  }\r
- bottom: "pad1"\r
+ bottom: "data"\r
  top: "conv1"\r
 }\r
 layers {\r
@@ -73,19 +65,11 @@ layers {
 # --------------------------- layer 2 ------------------------\r
 layers {\r
  layer {\r
-   name: "pad2"\r
-   type: "padding"\r
-   pad: 2\r
- }\r
- bottom: "norm1"\r
- top: "pad2"\r
-}\r
-layers {\r
- layer {\r
    name: "conv2"\r
    type: "conv"\r
    num_output: 32\r
    kernelsize: 5\r
+   pad: 2\r
    stride: 1\r
    weight_filler {\r
      type: "gaussian"\r
@@ -97,7 +81,7 @@ layers {
    blobs_lr: 1.\r
    blobs_lr: 2.\r
  }\r
- bottom: "pad2"\r
+ bottom: "norm1"\r
  top: "conv2"\r
 }\r
 layers {\r
@@ -133,19 +117,11 @@ layers {
 #-----------------------layer 3-------------------------\r
 layers {\r
  layer {\r
-   name: "pad3"\r
-   type: "padding"\r
-   pad: 2\r
- }\r
- bottom: "norm2"\r
- top: "pad3"\r
-}\r
-layers {\r
- layer {\r
    name: "conv3"\r
    type: "conv"\r
    num_output: 64\r
    kernelsize: 5\r
+   pad: 2\r
    stride: 1\r
    weight_filler {\r
      type: "gaussian"\r
@@ -155,7 +131,7 @@ layers {
      type: "constant"\r
    }\r
  }\r
- bottom: "pad3"\r
+ bottom: "norm2"\r
  top: "conv3"\r
 }\r
 layers {\r
similarity index 82%
rename from examples/cifar/cifar10_18pct.prototxt
rename to examples/cifar/cifar10_18pct_train.prototxt
index df74dd4..d185f53 100644 (file)
@@ -1,9 +1,9 @@
-name: "CIFAR10_18pct"\r
+name: "CIFAR10_18pct_train"\r
 layers {\r
  layer {\r
    name: "cifar"\r
    type: "data"\r
-   source: "cifar10_db/cifar-train-leveldb"\r
+   source: "cifar10-leveldb/cifar-train-leveldb"\r
    meanfile: "mean.binaryproto"\r
    batchsize: 100\r
  }\r
@@ -13,19 +13,11 @@ layers {
 # ------------------------ layer 1 -----------------------------\r
 layers {\r
  layer {\r
-   name: "pad1"\r
-   type: "padding"\r
-   pad: 2\r
- }\r
- bottom: "data"\r
- top: "pad1"\r
-}\r
-layers {\r
- layer {\r
    name: "conv1"\r
    type: "conv"\r
    num_output: 32\r
    kernelsize: 5\r
+   pad: 2\r
    stride: 1\r
    weight_filler {\r
      type: "gaussian"\r
@@ -37,7 +29,7 @@ layers {
    blobs_lr: 1.\r
    blobs_lr: 2.\r
  }\r
- bottom: "pad1"\r
+ bottom: "data"\r
  top: "conv1"\r
 }\r
 layers {\r
@@ -73,19 +65,11 @@ layers {
 # --------------------------- layer 2 ------------------------\r
 layers {\r
  layer {\r
-   name: "pad2"\r
-   type: "padding"\r
-   pad: 2\r
- }\r
- bottom: "norm1"\r
- top: "pad2"\r
-}\r
-layers {\r
- layer {\r
    name: "conv2"\r
    type: "conv"\r
    num_output: 32\r
    kernelsize: 5\r
+   pad: 2\r
    stride: 1\r
    weight_filler {\r
      type: "gaussian"\r
@@ -97,7 +81,7 @@ layers {
    blobs_lr: 1.\r
    blobs_lr: 2.\r
  }\r
- bottom: "pad2"\r
+ bottom: "norm1"\r
  top: "conv2"\r
 }\r
 layers {\r
@@ -133,19 +117,11 @@ layers {
 #-----------------------layer 3-------------------------\r
 layers {\r
  layer {\r
-   name: "pad3"\r
-   type: "padding"\r
-   pad: 2\r
- }\r
- bottom: "norm2"\r
- top: "pad3"\r
-}\r
-layers {\r
- layer {\r
    name: "conv3"\r
    type: "conv"\r
    num_output: 64\r
    kernelsize: 5\r
+   pad: 2\r
    stride: 1\r
    weight_filler {\r
      type: "gaussian"\r
@@ -155,7 +131,7 @@ layers {
      type: "constant"\r
    }\r
  }\r
- bottom: "pad3"\r
+ bottom: "norm2"\r
  top: "conv3"\r
 }\r
 layers {\r
index b414bb9..1c224c7 100644 (file)
@@ -1,7 +1,7 @@
 # reduce the learning rate after 8 epochs (4000 iters) by a factor of 10
 
 # The training protocol buffer definition
-train_net: "cifar10_80sec.prototxt"
+train_net: "cifar10_80sec_train.prototxt"
 # The testing protocol buffer definition
 test_net: "cifar10_80sec_test.prototxt"
 # test_iter specifies how many forward passes the test should carry out.
@@ -19,7 +19,7 @@ lr_policy: "fixed"
 # Display every 100 iterations
 display: 100
 # The maximum number of iterations
-max_iter: 100000
+max_iter: 4000
 # snapshot intermediate results
 snapshot: 4000
 snapshot_prefix: "cifar10_80sec"
diff --git a/examples/cifar/cifar10_80sec_solver_lr1.prototxt b/examples/cifar/cifar10_80sec_solver_lr1.prototxt
new file mode 100644 (file)
index 0000000..b1ec9ae
--- /dev/null
@@ -0,0 +1,29 @@
+# reduce the learning rate after 8 epochs (4000 iters) by a factor of 10
+
+# The training protocol buffer definition
+train_net: "cifar10_80sec_train.prototxt"
+# The testing protocol buffer definition
+test_net: "cifar10_80sec_test.prototxt"
+# test_iter specifies how many forward passes the test should carry out.
+# In the case of MNIST, we have test batch size 100 and 100 test iterations,
+# covering the full 10,000 testing images.
+test_iter: 100
+# Carry out testing every 500 training iterations.
+test_interval: 500
+# The base learning rate, momentum and the weight decay of the network.
+base_lr: 0.0001
+momentum: 0.9
+weight_decay: 0.004
+# The learning rate policy
+lr_policy: "fixed"
+# Display every 100 iterations
+display: 100
+# The maximum number of iterations
+max_iter: 5000
+# snapshot intermediate results
+snapshot: 5000
+snapshot_prefix: "cifar10_80sec"
+# solver mode: 0 for CPU and 1 for GPU
+solver_mode: 1
+
+device_id: 1
index 0aa4b43..71714da 100644 (file)
@@ -1,10 +1,10 @@
-# test 80sec config\r
+# 80sec config\r
 name: "CIFAR10_80sec_test"\r
 layers {\r
  layer {\r
    name: "cifar"\r
    type: "data"\r
-   source: "cifar10_db/cifar-test-leveldb"\r
+   source: "cifar10-leveldb/cifar-test-leveldb"\r
    meanfile: "mean.binaryproto"\r
    batchsize: 100\r
  }\r
@@ -14,19 +14,11 @@ layers {
 # ------------------------ layer 1 -----------------------------\r
 layers {\r
  layer {\r
-   name: "pad1"\r
-   type: "padding"\r
-   pad: 2\r
- }\r
- bottom: "data"\r
- top: "pad1"\r
-}\r
-layers {\r
- layer {\r
    name: "conv1"\r
    type: "conv"\r
    num_output: 32\r
    kernelsize: 5\r
+   pad: 2\r
    stride: 1\r
    weight_filler {\r
      type: "gaussian"\r
@@ -38,7 +30,7 @@ layers {
    blobs_lr: 1.0\r
    blobs_lr: 2.0\r
  }\r
- bottom: "pad1"\r
+ bottom: "data"\r
  top: "conv1"\r
 }\r
 layers {\r
@@ -63,19 +55,11 @@ layers {
 # --------------------------- layer 2 ------------------------\r
 layers {\r
  layer {\r
-   name: "pad2"\r
-   type: "padding"\r
-   pad: 2\r
- }\r
- bottom: "pool1"\r
- top: "pad2"\r
-}\r
-layers {\r
- layer {\r
    name: "conv2"\r
    type: "conv"\r
    num_output: 32\r
    kernelsize: 5\r
+   pad: 2\r
    stride: 1\r
    weight_filler {\r
      type: "gaussian"\r
@@ -87,7 +71,7 @@ layers {
    blobs_lr: 1.0\r
    blobs_lr: 2.0\r
  }\r
- bottom: "pad2"\r
+ bottom: "pool1"\r
  top: "conv2"\r
 }\r
 layers {\r
@@ -112,19 +96,11 @@ layers {
 #-----------------------layer 3-------------------------\r
 layers {\r
  layer {\r
-   name: "pad3"\r
-   type: "padding"\r
-   pad: 2\r
- }\r
- bottom: "pool2"\r
- top: "pad3"\r
-}\r
-layers {\r
- layer {\r
    name: "conv3"\r
    type: "conv"\r
    num_output: 64\r
    kernelsize: 5\r
+   pad: 2\r
    stride: 1\r
    weight_filler {\r
      type: "gaussian"\r
@@ -136,7 +112,7 @@ layers {
    blobs_lr: 1.0\r
    blobs_lr: 2.0\r
  }\r
- bottom: "pad3"\r
+ bottom: "pool2"\r
  top: "conv3"\r
 }\r
 layers {\r
similarity index 82%
rename from examples/cifar/cifar10_80sec.prototxt
rename to examples/cifar/cifar10_80sec_train.prototxt
index 8d24a16..624d988 100644 (file)
@@ -1,10 +1,10 @@
-# test 80sec config\r
-name: "CIFAR10_80sec"\r
+# 80sec config\r
+name: "CIFAR10_80sec_train"\r
 layers {\r
  layer {\r
    name: "cifar"\r
    type: "data"\r
-   source: "cifar10_db/cifar-train-leveldb"\r
+   source: "cifar10-leveldb/cifar-train-leveldb"\r
    meanfile: "mean.binaryproto"\r
    batchsize: 100\r
  }\r
@@ -14,19 +14,11 @@ layers {
 # ------------------------ layer 1 -----------------------------\r
 layers {\r
  layer {\r
-   name: "pad1"\r
-   type: "padding"\r
-   pad: 2\r
- }\r
- bottom: "data"\r
- top: "pad1"\r
-}\r
-layers {\r
- layer {\r
    name: "conv1"\r
    type: "conv"\r
    num_output: 32\r
    kernelsize: 5\r
+   pad: 2\r
    stride: 1\r
    weight_filler {\r
      type: "gaussian"\r
@@ -38,7 +30,7 @@ layers {
    blobs_lr: 1.0\r
    blobs_lr: 2.0\r
  }\r
- bottom: "pad1"\r
+ bottom: "data"\r
  top: "conv1"\r
 }\r
 layers {\r
@@ -63,19 +55,11 @@ layers {
 # --------------------------- layer 2 ------------------------\r
 layers {\r
  layer {\r
-   name: "pad2"\r
-   type: "padding"\r
-   pad: 2\r
- }\r
- bottom: "pool1"\r
- top: "pad2"\r
-}\r
-layers {\r
- layer {\r
    name: "conv2"\r
    type: "conv"\r
    num_output: 32\r
    kernelsize: 5\r
+   pad: 2\r
    stride: 1\r
    weight_filler {\r
      type: "gaussian"\r
@@ -87,7 +71,7 @@ layers {
    blobs_lr: 1.0\r
    blobs_lr: 2.0\r
  }\r
- bottom: "pad2"\r
+ bottom: "pool1"\r
  top: "conv2"\r
 }\r
 layers {\r
@@ -112,19 +96,11 @@ layers {
 #-----------------------layer 3-------------------------\r
 layers {\r
  layer {\r
-   name: "pad3"\r
-   type: "padding"\r
-   pad: 2\r
- }\r
- bottom: "pool2"\r
- top: "pad3"\r
-}\r
-layers {\r
- layer {\r
    name: "conv3"\r
    type: "conv"\r
    num_output: 64\r
    kernelsize: 5\r
+   pad: 2\r
    stride: 1\r
    weight_filler {\r
      type: "gaussian"\r
@@ -136,7 +112,7 @@ layers {
    blobs_lr: 1.0\r
    blobs_lr: 2.0\r
  }\r
- bottom: "pad3"\r
+ bottom: "pool2"\r
  top: "conv3"\r
 }\r
 layers {\r
diff --git a/examples/cifar/create_cifar10.sh b/examples/cifar/create_cifar10.sh
new file mode 100755 (executable)
index 0000000..2d8428b
--- /dev/null
@@ -0,0 +1,19 @@
+#!/usr/bin/env sh
+# This script converts the cifar data into leveldb format.
+
+EXAMPLES=../../build/examples/cifar
+DATA=../../data/cifar10
+TOOLS=../../build/tools
+
+echo "Creating leveldb..."
+
+rm -rf cifar10-leveldb
+mkdir cifar10-leveldb
+
+$EXAMPLES/convert_cifar_data.bin $DATA ./cifar10-leveldb
+
+echo "Computing image mean..."
+
+$TOOLS/compute_image_mean.bin ./cifar10-leveldb/cifar-train-leveldb mean.binaryproto
+
+echo "Done."
diff --git a/examples/cifar/train_18pct.sh b/examples/cifar/train_18pct.sh
new file mode 100755 (executable)
index 0000000..6a562ec
--- /dev/null
@@ -0,0 +1,11 @@
+#!/usr/bin/env sh
+
+TOOLS=../../build/tools
+
+GLOG_logtostderr=1 $TOOLS/train_net.bin cifar10_18pct_solver.prototxt
+
+#reduce learning rate by factor of 10
+GLOG_logtostderr=1 $TOOLS/train_net.bin cifar10_18pct_solver_lr1.prototxt cifar10_18pct_iter_60000.solverstate
+
+#reduce learning rate by factor of 10
+GLOG_logtostderr=1 $TOOLS/train_net.bin cifar10_18pct_solver_lr2.prototxt cifar10_18pct_iter_65000.solverstate
diff --git a/examples/cifar/train_80sec.sh b/examples/cifar/train_80sec.sh
new file mode 100755 (executable)
index 0000000..a55a870
--- /dev/null
@@ -0,0 +1,8 @@
+#!/usr/bin/env sh
+
+TOOLS=../../build/tools
+
+GLOG_logtostderr=1 $TOOLS/train_net.bin cifar10_80sec_solver.prototxt
+
+#reduce learning rate by fctor of 10 after 8 epochs
+GLOG_logtostderr=1 $TOOLS/train_net.bin cifar10_80sec_solver_lr1.prototxt cifar10_80sec_iter_4000.solverstate