You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@singa.apache.org by wa...@apache.org on 2016/06/03 07:48:24 UTC
[19/60] incubator-singa git commit: SINGA-163 - Reorganize the
project folder layout
http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/dd1e4afa/examples/alexnet/Makefile.example
----------------------------------------------------------------------
diff --git a/examples/alexnet/Makefile.example b/examples/alexnet/Makefile.example
deleted file mode 100644
index f895146..0000000
--- a/examples/alexnet/Makefile.example
+++ /dev/null
@@ -1,29 +0,0 @@
-#/**
-# * Licensed to the Apache Software Foundation (ASF) under one
-# * or more contributor license agreements. See the NOTICE file
-# * distributed with this work for additional information
-# * regarding copyright ownership. The ASF licenses this file
-# * to you under the Apache License, Version 2.0 (the
-# * "License"); you may not use this file except in compliance
-# * with the License. You may obtain a copy of the License at
-# *
-# * http://www.apache.org/licenses/LICENSE-2.0
-# *
-# * Unless required by applicable law or agreed to in writing, software
-# * distributed under the License is distributed on an "AS IS" BASIS,
-# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# * See the License for the specific language governing permissions and
-# * limitations under the License.
-# */
-
-libs :=singa glog protobuf
-
-.PHONY: all create
-
-create:
- $(CXX) im2rec.cc `pkg-config opencv --cflags --libs` -std=c++11 -lsinga -lprotobuf -lglog \
- -I../../include -L../../.libs/ -Wl,-unresolved-symbols=ignore-in-shared-libs \
- -Wl,-rpath=../../.libs/ -o im2rec.bin
- $(CXX) rec2im_test.cc `pkg-config opencv --cflags --libs` -std=c++11 -lsinga -lprotobuf -lglog \
- -I../../include -L../../.libs/ -Wl,-unresolved-symbols=ignore-in-shared-libs \
- -Wl,-rpath=../../.libs/ -o rec2im_test.bin
http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/dd1e4afa/examples/alexnet/cudnn.conf
----------------------------------------------------------------------
diff --git a/examples/alexnet/cudnn.conf b/examples/alexnet/cudnn.conf
deleted file mode 100644
index e8d14c6..0000000
--- a/examples/alexnet/cudnn.conf
+++ /dev/null
@@ -1,448 +0,0 @@
-name: "alexnet"
-train_steps: 450000
-test_steps: 500
-test_freq: 1000
-disp_freq: 20
-checkpoint_freq: 100000
-checkpoint_after: 100000
-gpu: 0
-#debug: true
-#checkpoint_path: "examples/alexnet/checkpoint/step10000-worker0"
-train_one_batch {
- alg: kBP
-}
-updater{
- type: kSGD
- weight_decay: 0.0005
- momentum: 0.9
- learning_rate {
- type: kStep
- base_lr: 0.01
- step_conf {
- gamma: 0.1
- change_freq: 100000
- }
- }
-}
-neuralnet {
- layer{
- name: "data"
- type: kRecordInput
- store_conf {
- backend: "kvfile"
- path :"/data/dataset/imagenet/train_record.bin"
- mean_file: "/data/dataset/imagenet/image_mean.bin"
- batchsize: 256
- #random_skip: 1000
- shape: 3
- shape: 256
- shape: 256
- }
- include: kTrain
- }
- layer{
- name: "data"
- type: kRecordInput
- store_conf {
- backend: "kvfile"
- path :"/data/dataset/imagenet/val_record.bin"
- mean_file: "/data/dataset/imagenet/image_mean.bin"
- batchsize: 100
- shape: 3
- shape: 256
- shape: 256
- }
- include: kTest
- }
- layer{
- name: "image"
- type: kImagePreprocess
- rgbimage_conf {
- cropsize: 227
- mirror: true
- }
-# partition_dim: 0
- srclayers: "data"
- }
- layer{
- name: "conv1"
- type: kCudnnConv
- srclayers: "image"
- convolution_conf {
- num_filters: 96
- kernel: 11
- stride: 4
- }
-# partition_dim: 0
- param {
- name: "w1"
- init {
- type: kGaussian
- std: 0.01
- }
- }
- param {
- name: "b1"
- lr_scale: 2
- wd_scale: 0
- init {
- type: kConstant
- value: 0
- }
- }
- }
- layer {
- name: "relu1"
- type: kCudnnActivation
- activation_conf {
- type: RELU
- }
- share_src_blobs: true
- srclayers: "conv1"
-# partition_dim: 0
- }
- layer {
- name: "pool1"
- type: kCudnnPool
- pooling_conf {
- pool: MAX
- kernel: 3
- stride: 2
- }
- srclayers: "relu1"
-# partition_dim: 0
- }
- layer {
- name: "norm1"
- type: kCudnnLRN
- lrn_conf {
- local_size: 5
- alpha: 0.0001
- beta: 0.75
- knorm: 1
- }
- srclayers: "pool1"
-# partition_dim: 0
- }
-
- layer{
- name: "conv2"
- type: kCudnnConv
- srclayers: "norm1"
- convolution_conf {
- num_filters: 256
- kernel: 5
- pad: 2
- }
-# partition_dim: 0
- param {
- name: "w2"
- init {
- type: kGaussian
- std: 0.01
- }
- }
- param {
- name: "b2"
- lr_scale: 2
- wd_scale: 0
- init {
- type: kConstant
- value: 1
- }
- }
- }
- layer {
- name: "relu2"
- type: kCudnnActivation
- activation_conf {
- type: RELU
- }
- share_src_blobs: true
- srclayers: "conv2"
-# partition_dim: 0
- }
- layer {
- name: "pool2"
- type: kCudnnPool
- pooling_conf {
- pool: MAX
- kernel: 3
- stride: 2
- }
- srclayers: "relu2"
-# partition_dim: 0
- }
-
- layer {
- name: "norm2"
- type: kCudnnLRN
- lrn_conf {
- local_size: 5
- alpha: 0.0001
- beta: 0.75
- knorm: 1
- }
- srclayers: "pool2"
-# partition_dim: 0
- }
- layer{
- name: "conv3"
- type: kCudnnConv
- srclayers: "norm2"
- convolution_conf {
- num_filters: 384
- kernel: 3
- pad: 1
- }
-# partition_dim: 0
- param {
- name: "w3"
- init {
- type: kGaussian
- std: 0.01
- }
- }
- param {
- name: "b3"
- lr_scale: 2
- wd_scale: 0
- init {
- type: kConstant
- value: 0
- }
- }
- }
- layer {
- name: "relu3"
- type: kCudnnActivation
- activation_conf {
- type: RELU
- }
- share_src_blobs: true
- srclayers: "conv3"
-# partition_dim: 0
- }
- layer{
- name: "conv4"
- type: kCudnnConv
- srclayers: "relu3"
- convolution_conf {
- num_filters: 384
- kernel: 3
- pad: 1
- }
-# partition_dim: 0
- param {
- name: "w4"
- init {
- type: kGaussian
- std: 0.01
- }
- }
- param {
- name: "b4"
- lr_scale:2
- wd_scale:0
- init {
- type: kConstant
- value: 1
- }
- }
- }
- layer {
- name: "relu4"
- type: kCudnnActivation
- activation_conf {
- type: RELU
- }
- share_src_blobs: true
- srclayers: "conv4"
-# partition_dim: 0
- }
- layer{
- name: "conv5"
- type: kCudnnConv
- srclayers: "relu4"
- convolution_conf {
- num_filters: 256
- kernel: 3
- pad: 1
- }
-# partition_dim: 0
- param {
- name: "w5"
- init {
- type: kGaussian
- std: 0.01
- }
- }
- param {
- name: "b5"
- lr_scale: 2
- wd_scale: 0
- init {
- type: kConstant
- value: 1
- }
- }
- }
- layer {
- name: "relu5"
- type: kCudnnActivation
- activation_conf {
- type: RELU
- }
- share_src_blobs: true
- srclayers: "conv5"
-# partition_dim: 0
- }
- layer {
- name: "pool5"
- type: kCudnnPool
- pooling_conf {
- pool: MAX
- kernel: 3
- stride: 2
- }
- srclayers: "relu5"
-# partition_dim: 0
- }
- layer {
- name: "ip6"
- type: kInnerProduct
- innerproduct_conf {
- num_output: 4096
- }
- param {
- name: "w6"
- init {
- type: kGaussian
- std: 0.005
- }
- }
- param {
- name: "b6"
- lr_scale: 2
- wd_scale: 0
- init {
- type: kConstant
- value: 1
- }
- }
- srclayers: "pool5"
-# partition_dim: 1
- }
- layer {
- name: "relu6"
- type: kCudnnActivation
- activation_conf {
- type: RELU
- }
- share_src_blobs: true
- srclayers: "ip6"
-# partition_dim: 1
- }
- layer {
- name: "drop6"
- type: kDropout
- srclayers: "relu6"
-# partition_dim: 1
- }
- layer {
- name: "ip7"
- type: kInnerProduct
- innerproduct_conf {
- num_output: 4096
- }
-# partition_dim: 1
- param {
- name: "w7"
- init {
- type: kGaussian
- std: 0.005
- }
- }
- param {
- name: "b7"
- lr_scale: 2
- wd_scale: 0
- init {
- type: kConstant
- value: 1
- }
- }
- srclayers: "drop6"
- }
- layer {
- name: "relu7"
- type: kCudnnActivation
- activation_conf {
- type: RELU
- }
- share_src_blobs: true
- srclayers: "ip7"
-# partition_dim: 1
- }
- layer {
- name: "drop7"
- type: kDropout
- srclayers: "relu7"
-# partition_dim: 1
- }
- layer {
- name: "ip8"
- type: kInnerProduct
- innerproduct_conf {
- num_output: 1000
- }
-# partition_dim: 1
- param {
- name: "w8"
- init {
- type: kGaussian
- std: 0.01
- }
- }
- param {
- name: "b8"
- lr_scale: 2
- wd_scale: 0
- init {
- type: kConstant
- value: 0
- }
- }
- srclayers: "drop7"
- }
- layer {
- name: "loss"
- type: kCudnnSoftmaxLoss
- softmaxloss_conf {
- topk:1
- }
- srclayers: "ip8"
- srclayers: "data"
- include: kTrain
- }
- layer {
- name : "softmax"
- type: kCudnnSoftmax
- srclayers: "ip8"
- include: kTest
- }
- layer {
- name : "accuracy"
- type: kAccuracy
- srclayers: "softmax"
- srclayers: "data"
- include: kTest
- }
-}
-cluster {
- nworker_groups: 1
- nserver_groups: 1
- nworkers_per_group: 1
- nworkers_per_procs: 1
- workspace: "examples/alexnet"
-}
http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/dd1e4afa/examples/alexnet/im2rec.cc
----------------------------------------------------------------------
diff --git a/examples/alexnet/im2rec.cc b/examples/alexnet/im2rec.cc
deleted file mode 100644
index 58ee44f..0000000
--- a/examples/alexnet/im2rec.cc
+++ /dev/null
@@ -1,157 +0,0 @@
-/************************************************************
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*************************************************************/
-
-
-#include <glog/logging.h>
-#include <opencv2/opencv.hpp>
-#include <algorithm>
-#include <random>
-#include <chrono>
-#include <fstream>
-#include <string>
-#include <cstdint>
-#include <iostream>
-#include <vector>
-
-#include "singa/io/store.h"
-#include "singa/proto/common.pb.h"
-
-using std::string;
-
-const int kImageSize = 256;
-const int kImageNBytes = 256*256*3;
-
-void create_data(const string& image_list,
- const string& input_folder,
- const string& output_folder,
- const string& backend = "kvfile") {
- singa::RecordProto image;
- image.add_shape(3);
- image.add_shape(kImageSize);
- image.add_shape(kImageSize);
-
- singa::RecordProto mean;
- mean.CopyFrom(image);
- for (int i = 0; i < kImageNBytes; ++i)
- mean.add_data(0.f);
-
- auto store = singa::io::CreateStore(backend);
- if (backend == "lmdb")
- CHECK(store->Open(output_folder + "/image_record", singa::io::kCreate));
- else
- CHECK(store->Open(output_folder + "/image_record.bin", singa::io::kCreate));
-
- LOG(INFO) << "Generating image record";
-
- std::ifstream image_list_file(image_list.c_str(), std::ios::in);
- CHECK(image_list_file.is_open()) << "Unable to open image list";
-
- string image_file_name;
- int label;
- char str_buffer[kImageNBytes];
- string rec_buf;
- cv::Mat img, res;
- std::vector<std::pair<string, int>> file_list;
- while (image_list_file >> image_file_name >> label)
- file_list.push_back(std::make_pair(image_file_name, label));
- LOG(INFO) << "Data Shuffling";
- unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
- std::shuffle(file_list.begin(), file_list.end()
- , std::default_random_engine());
- LOG(INFO) << "Total number of images is " << file_list.size();
- int ImageNum = file_list.size();
-
- for (int imageid = 0; imageid < ImageNum; ++imageid) {
- string path = input_folder + "/" + file_list[imageid].first;
- img = cv::imread(path, CV_LOAD_IMAGE_COLOR);
- CHECK(img.data != NULL) << "OpenCV load image fail" << path;
- cv::resize(img, res, cv::Size(kImageSize, kImageSize),
- 0, 0, CV_INTER_LINEAR);
- for (int h = 0; h < kImageSize; ++h) {
- const uchar* ptr = res.ptr<uchar>(h);
- int img_index = 0;
- for (int w = 0; w < kImageSize; ++w)
- for (int c = 0; c < 3; ++c)
- str_buffer[(c*kImageSize+h)*kImageSize+w] =
- static_cast<uint8_t>(ptr[img_index++]);
- }
- /*
- for (int i = 0; i < kImageSize; ++i) {
- for (int j = 0; j < kImageSize; ++j) {
- cv::Vec3b pixel = res.at<cv::Vec3b>(j, i);
- str_buffer[i*kImageSize+j] = static_cast<uint8_t>(pixel.val[2]);
- str_buffer[kImageSize*kImageSize+i*kImageSize+j] = static_cast<uint8_t>(pixel.val[1]);
- str_buffer[kImageSize*kImageSize*2+i*kImageSize+j] = static_cast<uint8_t>(pixel.val[0]);
- }
- }
- */
- image.set_label(file_list[imageid].second);
- image.set_pixel(str_buffer, kImageNBytes);
- image.SerializeToString(&rec_buf);
-
- int length = snprintf(str_buffer, kImageNBytes, "%08d", imageid);
- CHECK(store->Write(string(str_buffer, length), rec_buf));
- if ((imageid+1) % 1000 == 0) {
- store->Flush();
- LOG(INFO) << imageid+1 << " files processed.";
- }
- const string& pixels = image.pixel();
- for (int i = 0; i < kImageNBytes; ++i)
- mean.set_data(i, mean.data(i) + static_cast<uint8_t>(pixels[i]));
- }
- if (ImageNum % 1000 != 0)
- LOG(INFO) << ImageNum << " files processed.";
-
- store->Flush();
- store->Close();
-
- LOG(INFO) << "Create image mean";
- if (backend == "lmdb")
- CHECK(store->Open(output_folder + "/image_mean", singa::io::kCreate));
- else
- CHECK(store->Open(output_folder + "/image_mean.bin", singa::io::kCreate));
- for (int i = 0; i < kImageNBytes; i++)
- mean.set_data(i, mean.data(i) / ImageNum);
- mean.SerializeToString(&rec_buf);
- store->Write("mean", rec_buf);
- store->Flush();
- store->Close();
- delete store;
-
- LOG(INFO) << "Done!";
-}
-
-int main(int argc, char** argv) {
- if (argc < 4) {
- std::cout << "Create data stores for ImageNet dataset.\n"
- << "Usage: <image_list_file> <input_image_folder> <output_folder>"
- << " <Optional: backend {lmdb, kvfile} default: kvfile>\n";
- } else {
- google::InitGoogleLogging(argv[0]);
- FLAGS_alsologtostderr = 1;
- if (argc == 4)
- create_data(string(argv[1]), string(argv[2]), string(argv[3]));
- else
- create_data(string(argv[1]), string(argv[2]),
- string(argv[3]), string(argv[4]));
- }
- return 0;
-}
http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/dd1e4afa/examples/alexnet/job.conf
----------------------------------------------------------------------
diff --git a/examples/alexnet/job.conf b/examples/alexnet/job.conf
deleted file mode 100644
index 3b7eaf4..0000000
--- a/examples/alexnet/job.conf
+++ /dev/null
@@ -1,403 +0,0 @@
-name: "alexnet"
-train_steps: 450000
-test_steps: 500
-test_freq: 1000
-disp_freq: 20
-checkpoint_freq: 100000
-checkpoint_after: 100000
-train_one_batch {
- alg: kBP
-}
-updater{
- type: kSGD
- weight_decay: 0.0005
- momentum: 0.9
- learning_rate {
- type: kStep
- base_lr: 0.01
- step_conf {
- gamma: 0.1
- change_freq: 100000
- }
- }
-}
-neuralnet {
- layer{
- name: "data"
- type: kRecordInput
- store_conf {
- backend: "kvfile"
- path :"/data/dataset/imagenet/train_record.bin"
- mean_file: "/data/dataset/imagenet/image_mean.bin"
- batchsize: 256
- #random_skip: 1000
- shape: 3
- shape: 256
- shape: 256
- }
- include: kTrain
- }
- layer{
- name: "data"
- type: kRecordInput
- store_conf {
- backend: "kvfile"
- path :"/data/dataset/imagenet/val_record.bin"
- mean_file: "/data/dataset/imagenet/image_mean.bin"
- batchsize: 100
- shape: 3
- shape: 256
- shape: 256
- }
- include: kTest
- }
- layer{
- name: "image"
- type: kImagePreprocess
- rgbimage_conf {
- cropsize: 227
- mirror: true
- }
-# partition_dim: 0
- srclayers: "data"
- }
- layer{
- name: "conv1"
- type: kConvolution
- srclayers: "image"
- convolution_conf {
- num_filters: 96
- kernel: 11
- stride: 4
- }
-# partition_dim: 0
- param {
- name: "w1"
- init {
- type: kGaussian
- std: 0.01
- }
- }
- param {
- name: "b1"
- lr_scale: 2
- wd_scale: 0
- init {
- type: kConstant
- value: 0
- }
- }
- }
- layer {
- name: "relu1"
- type: kReLU
- srclayers: "conv1"
-# partition_dim: 0
- }
- layer {
- name: "pool1"
- type: kPooling
- pooling_conf {
- pool: MAX
- kernel: 3
- stride: 2
- }
- srclayers: "relu1"
-# partition_dim: 0
- }
- layer {
- name: "norm1"
- type: kLRN
- lrn_conf {
- local_size: 5
- alpha: 0.0001
- beta: 0.75
- knorm: 1
- }
- srclayers: "pool1"
-# partition_dim: 0
- }
-
- layer{
- name: "conv2"
- type: kConvolution
- srclayers: "norm1"
- convolution_conf {
- num_filters: 256
- kernel: 5
- pad: 2
- }
-# partition_dim: 0
- param {
- name: "w2"
- init {
- type: kGaussian
- std: 0.01
- }
- }
- param {
- name: "b2"
- lr_scale: 2
- wd_scale: 0
- init {
- type: kConstant
- value: 1
- }
- }
- }
- layer {
- name: "relu2"
- type: kReLU
- srclayers: "conv2"
-# partition_dim: 0
- }
- layer {
- name: "pool2"
- type: kPooling
- pooling_conf {
- pool: MAX
- kernel: 3
- stride: 2
- }
- srclayers: "relu2"
-# partition_dim: 0
- }
-
- layer {
- name: "norm2"
- type: kLRN
- lrn_conf {
- local_size: 5
- alpha: 0.0001
- beta: 0.75
- knorm: 1
- }
- srclayers: "pool2"
-# partition_dim: 0
- }
- layer{
- name: "conv3"
- type: kConvolution
- srclayers: "norm2"
- convolution_conf {
- num_filters: 384
- kernel: 3
- pad: 1
- }
-# partition_dim: 0
- param {
- name: "w3"
- init {
- type: kGaussian
- std: 0.01
- }
- }
- param {
- name: "b3"
- lr_scale: 2
- wd_scale: 0
- init {
- type: kConstant
- value: 0
- }
- }
- }
- layer {
- name: "relu3"
- type: kReLU
- srclayers: "conv3"
-# partition_dim: 0
- }
- layer{
- name: "conv4"
- type: kConvolution
- srclayers: "relu3"
- convolution_conf {
- num_filters: 384
- kernel: 3
- pad: 1
- }
-# partition_dim: 0
- param {
- name: "w4"
- init {
- type: kGaussian
- std: 0.01
- }
- }
- param {
- name: "b4"
- lr_scale:2
- wd_scale:0
- init {
- type: kConstant
- value: 1
- }
- }
- }
- layer {
- name: "relu4"
- type: kReLU
- srclayers: "conv4"
-# partition_dim: 0
- }
- layer{
- name: "conv5"
- type: kConvolution
- srclayers: "relu4"
- convolution_conf {
- num_filters: 256
- kernel: 3
- pad: 1
- }
-# partition_dim: 0
- param {
- name: "w5"
- init {
- type: kGaussian
- std: 0.01
- }
- }
- param {
- name: "b5"
- lr_scale: 2
- wd_scale: 0
- init {
- type: kConstant
- value: 1
- }
- }
- }
- layer {
- name: "relu5"
- type: kReLU
- srclayers: "conv5"
-# partition_dim: 0
- }
- layer {
- name: "pool5"
- type: kPooling
- pooling_conf {
- pool: MAX
- kernel: 3
- stride: 2
- }
- srclayers: "relu5"
-# partition_dim: 0
- }
- layer {
- name: "ip6"
- type: kInnerProduct
- innerproduct_conf {
- num_output: 4096
- }
- param {
- name: "w6"
- init {
- type: kGaussian
- std: 0.005
- }
- }
- param {
- name: "b6"
- lr_scale: 2
- wd_scale: 0
- init {
- type: kConstant
- value: 1
- }
- }
- srclayers: "pool5"
-# partition_dim: 1
- }
- layer {
- name: "relu6"
- type: kReLU
- srclayers: "ip6"
-# partition_dim: 1
- }
- layer {
- name: "drop6"
- type: kDropout
- srclayers: "relu6"
-# partition_dim: 1
- }
- layer {
- name: "ip7"
- type: kInnerProduct
- innerproduct_conf {
- num_output: 4096
- }
-# partition_dim: 1
- param {
- name: "w7"
- init {
- type: kGaussian
- std: 0.005
- }
- }
- param {
- name: "b7"
- lr_scale: 2
- wd_scale: 0
- init {
- type: kConstant
- value: 1
- }
- }
- srclayers: "drop6"
- }
- layer {
- name: "relu7"
- type: kReLU
- srclayers: "ip7"
-# partition_dim: 1
- }
- layer {
- name: "drop7"
- type: kDropout
- srclayers: "relu7"
-# partition_dim: 1
- }
- layer {
- name: "ip8"
- type: kInnerProduct
- innerproduct_conf {
- num_output: 1000
- }
-# partition_dim: 1
- param {
- name: "w8"
- init {
- type: kGaussian
- std: 0.01
- }
- }
- param {
- name: "b8"
- lr_scale: 2
- wd_scale: 0
- init {
- type: kConstant
- value: 0
- }
- }
- srclayers: "drop7"
- }
- layer {
- name: "loss"
- type: kSoftmaxLoss
- softmaxloss_conf {
- topk:1
- }
- srclayers: "ip8"
- srclayers: "data"
- }
-}
-cluster {
- nworker_groups: 1
- nserver_groups: 1
- nworkers_per_group: 1
- nworkers_per_procs: 1
- workspace: "examples/alexnet"
-}
http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/dd1e4afa/examples/alexnet/rec2im_test.cc
----------------------------------------------------------------------
diff --git a/examples/alexnet/rec2im_test.cc b/examples/alexnet/rec2im_test.cc
deleted file mode 100644
index bb92d95..0000000
--- a/examples/alexnet/rec2im_test.cc
+++ /dev/null
@@ -1,116 +0,0 @@
-/************************************************************
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*************************************************************/
-
-
-#include <glog/logging.h>
-#include <opencv2/opencv.hpp>
-
-#include <algorithm>
-#include <random>
-#include <chrono>
-#include <fstream>
-#include <string>
-#include <cstdint>
-#include <iostream>
-#include <vector>
-
-#include "singa/io/store.h"
-#include "singa/proto/common.pb.h"
-
-using std::string;
-
-const int kImageSize = 256;
-const int kImageNBytes = 256*256*3;
-
-void generate_image(const string& output_folder,
- const string& key,
- const string& val) {
- float image_buf[kImageNBytes];
- singa::RecordProto image;
- image.ParseFromString(val);
- cv::Mat img = cv::Mat::zeros(kImageSize, kImageSize, CV_8UC3);
- string pixel = image.pixel();
- int label = image.label();
- string image_name = output_folder+"/"+key+"_"+std::to_string(label)+".jpg";
- std::cout << "Writing to " << image_name << "...\n";
- for (int h = 0; h < kImageSize; ++h) {
- uchar* ptr = img.ptr<uchar>(h);
- int img_index = 0;
- for (int w = 0; w < kImageSize; ++w) {
- for (int c = 0; c < 3; ++c)
- ptr[img_index++] =
- static_cast<uchar>(
- static_cast<uint8_t>(
- pixel[(c * kImageSize + h) * kImageSize + w]));
- }
- }
-
- cv::imwrite(image_name, img);
-}
-
-void visualize(const string& input_file,
- const string& output_folder,
- const string& id_list) {
- auto store = singa::io::OpenStore("kvfile", input_file,
- singa::io::kRead);
-
- std::vector<int> image_id_list;
-
- std::ifstream id_list_file(id_list.c_str(), std::ios::in);
- CHECK(id_list_file.is_open()) << "Unable to open image id list";
- string id_;
- while (id_list_file >> id_) {
- int x;
- x = std::stoi(id_);
- image_id_list.push_back(x);
- }
- std::sort(image_id_list.begin(), image_id_list.end());
-
- string key, val;
- for (int i = 0; i < image_id_list[0]; ++i)
- if (!store->Read(&key, &val)) {
- store->SeekToFirst();
- CHECK(store->Read(&key, &val));
- }
- generate_image(output_folder, key, val);
-
- for (size_t i = 1; i != image_id_list.size(); ++i) {
- for (int j = 0; j < image_id_list[i]-image_id_list[i-1]; ++j)
- if (!store->Read(&key, &val)) {
- store->SeekToFirst();
- CHECK(store->Read(&key, &val));
- }
- generate_image(output_folder, key, val);
- }
-}
-
-int main(int argc, char** argv) {
- if (argc != 4) {
- std::cout << "Visualize images from binary kvfile records.\n"
- << "Usage: <input_file> <output_folder> <id_list>\n";
- } else {
- google::InitGoogleLogging(argv[0]);
- FLAGS_alsologtostderr = 1;
- visualize(string(argv[1]), string(argv[2]), string(argv[3]));
- }
-
- return 0;
-}
http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/dd1e4afa/examples/char-rnn/data.py
----------------------------------------------------------------------
diff --git a/examples/char-rnn/data.py b/examples/char-rnn/data.py
deleted file mode 100644
index 20e7262..0000000
--- a/examples/char-rnn/data.py
+++ /dev/null
@@ -1,32 +0,0 @@
-#!/usr/bin/env python
-
-#/************************************************************
-#*
-#* Licensed to the Apache Software Foundation (ASF) under one
-#* or more contributor license agreements. See the NOTICE file
-#* distributed with this work for additional information
-#* regarding copyright ownership. The ASF licenses this file
-#* to you under the Apache License, Version 2.0 (the
-#* "License"); you may not use this file except in compliance
-#* with the License. You may obtain a copy of the License at
-#*
-#* http://www.apache.org/licenses/LICENSE-2.0
-#*
-#* Unless required by applicable law or agreed to in writing,
-#* software distributed under the License is distributed on an
-#* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-#* KIND, either express or implied. See the License for the
-#* specific language governing permissions and limitations
-#* under the License.
-#*
-#*************************************************************/
-
-
-# pls get linux_input.txt from http://cs.stanford.edu/people/karpathy/char-rnn/
-data = open('linux_input.txt', 'r').read() # should be simple plain text file
-chars = list(set(data))
-data_size, vocab_size = len(data), len(chars)
-print 'data has %d characters, %d unique.' % (data_size, vocab_size)
-with open('vocab.txt', 'w') as fd:
- fd.write("".join(chars))
- fd.flush()
http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/dd1e4afa/examples/char-rnn/job.conf
----------------------------------------------------------------------
diff --git a/examples/char-rnn/job.conf b/examples/char-rnn/job.conf
deleted file mode 100644
index bd648f1..0000000
--- a/examples/char-rnn/job.conf
+++ /dev/null
@@ -1,253 +0,0 @@
-name:"char-rnn"
-train_steps: 100000
-disp_freq: 100
-#debug: true
-gpu: 0
-train_one_batch {
- alg: kBPTT
-}
-
-updater {
- type: kRMSProp
- rmsprop_conf {
- rho: 0.95
- }
- learning_rate {
- type: kStep
- base_lr: 0.002
- step_conf {
- gamma: 0.97
- change_freq: 2000
- }
- }
- clip_low: -5
- clip_high: 5
-}
-
-neuralnet {
- unroll_len: 50
- layer {
- name: "data"
- type: kCharRNN
- unroll_len: 1
- char_rnn_conf {
- path: "examples/char-rnn/linux_input.txt"
- vocab_path:"examples/char-rnn/vocab.txt"
- batchsize: 50
- unroll_len: 50
- }
- }
- layer {
- name: "onehot"
- type: kOneHot
- srclayers: "data"
- unroll_conn_type: kUnrollOneToAll
- onehot_conf {
- vocab_size: 101
- }
- }
-
- layer {
- name: "label"
- type: kRNNLabel
- srclayers: "data"
- unroll_conn_type: kUnrollOneToAll
- }
-
- layer {
- name: "gru1"
- type: kGRU
- srclayers: "onehot"
- gru_conf {
- dim_hidden: 512
- }
- param {
- name: "z_hx"
- init {
- type: kUniform
- low: -0.08
- high: 0.08
- }
- }
- param {
- name: "r_hx"
- init {
- type: kUniform
- low: -0.08
- high: 0.08
- }
- }
- param {
- name: "c_hx"
- init {
- type: kUniform
- low: -0.08
- high: 0.08
- }
- }
- param {
- name: "z_hh"
- init {
- type: kUniform
- low: -0.08
- high: 0.08
- }
- }
- param {
- name: "r_hh"
- init {
- type: kUniform
- low: -0.08
- high: 0.08
- }
- }
- param {
- name: "c_hh"
- init {
- type: kUniform
- low: -0.08
- high: 0.08
- }
- }
- param {
- name: "z_b"
- init {
- type: kUniform
- low: -0.08
- high: 0.08
- }
- }
- param {
- name: "r_b"
- init {
- type: kUniform
- low: -0.08
- high: 0.08
- }
- }
- param {
- name: "c_b"
- init {
- type: kUniform
- low: -0.08
- high: 0.08
- }
- }
-
- }
-# layer {
-# name: "gru2"
-# type: kGRU
-# srclayers: "gru1"
-# gru_conf {
-# dim_hidden: 512
-# }
-# param {
-# name: "z_hx2"
-# init {
-# type: kUniform
-# low: -0.08
-# high: 0.08
-# }
-# }
-# param {
-# name: "r_hx2"
-# init {
-# type: kUniform
-# low: -0.08
-# high: 0.08
-# }
-# }
-# param {
-# name: "c_hx2"
-# init {
-# type: kUniform
-# low: -0.08
-# high: 0.08
-# }
-# }
-# param {
-# name: "z_hh2"
-# init {
-# type: kUniform
-# low: -0.08
-# high: 0.08
-# }
-# }
-# param {
-# name: "r_hh2"
-# init {
-# type: kUniform
-# low: -0.08
-# high: 0.08
-# }
-# }
-# param {
-# name: "c_hh2"
-# init {
-# type: kUniform
-# low: -0.08
-# high: 0.08
-# }
-# }
-# param {
-# name: "z_b2"
-# init {
-# type: kUniform
-# low: -0.08
-# high: 0.08
-# }
-# }
-# param {
-# name: "r_b2"
-# init {
-# type: kUniform
-# low: -0.08
-# high: 0.08
-# }
-# }
-# param {
-# name: "c_b2"
-# init {
-# type: kUniform
-# low: -0.08
-# high: 0.08
-# }
-# }
-# }
-#
- layer {
- name: "ip1"
- type: kInnerProduct
- srclayers: "gru1"
- innerproduct_conf {
- num_output: 101
- }
- param {
- name: "w"
- init {
- type: kUniform
- low: -0.08
- high: 0.08
- }
- }
- param {
- name: "b"
- init {
- type: kUniform
- low: -0.08
- high: 0.08
- }
- }
- }
- layer {
- name: "loss"
- type: kSoftmaxLoss
- srclayers: "ip1"
- srclayers: "label"
- }
-}
-
-cluster {
- workspace: "examples/char-rnn/"
-}
http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/dd1e4afa/examples/char-rnn/sample.conf
----------------------------------------------------------------------
diff --git a/examples/char-rnn/sample.conf b/examples/char-rnn/sample.conf
deleted file mode 100644
index b15ef9e..0000000
--- a/examples/char-rnn/sample.conf
+++ /dev/null
@@ -1,212 +0,0 @@
-name:"char-rnn"
-test_steps: 100
-#debug: true
-gpu: 0
-checkpoint_path: "examples/char-rnn/checkpoint/step2000-worker0"
-train_one_batch {
- alg: kBPTT
-}
-
-neuralnet {
- layer {
- name: "data"
- type: kRNNDummy
- rnn_dummy_conf {
- shape: 1
- integer: true
- low: 0
- high: 101
- dynamic_srclayer: "argsort"
- }
- }
- layer {
- name: "onehot"
- type: kOneHot
- srclayers: "data"
- }
-
- layer {
- name: "gru1"
- type: kGRU
- srclayers: "onehot"
- gru_conf {
- dim_hidden: 512
- }
- param {
- name: "z_hx"
- init {
- type: kUniform
- low: -0.08
- high: 0.08
- }
- }
- param {
- name: "r_hx"
- init {
- type: kUniform
- low: -0.08
- high: 0.08
- }
- }
- param {
- name: "c_hx"
- init {
- type: kUniform
- low: -0.08
- high: 0.08
- }
- }
- param {
- name: "z_hh"
- init {
- type: kUniform
- low: -0.08
- high: 0.08
- }
- }
- param {
- name: "r_hh"
- init {
- type: kUniform
- low: -0.08
- high: 0.08
- }
- }
- param {
- name: "c_hh"
- init {
- type: kUniform
- low: -0.08
- high: 0.08
- }
- }
- param {
- name: "z_b"
- init {
- type: kUniform
- low: -0.08
- high: 0.08
- }
- }
- param {
- name: "r_b"
- init {
- type: kUniform
- low: -0.08
- high: 0.08
- }
- }
- param {
- name: "c_b"
- init {
- type: kUniform
- low: -0.08
- high: 0.08
- }
- }
- }
- layer {
- name: "gru2"
- type: kGRU
- srclayers: "gru1"
- gru_conf {
- dim_hidden: 512
- }
- param {
- name: "z_hx2"
- init {
- type: kUniform
- low: -0.08
- high: 0.08
- }
- }
- param {
- name: "r_hx2"
- init {
- type: kUniform
- low: -0.08
- high: 0.08
- }
- }
- param {
- name: "c_hx2"
- init {
- type: kUniform
- low: -0.08
- high: 0.08
- }
- }
- param {
- name: "z_hh2"
- init {
- type: kUniform
- low: -0.08
- high: 0.08
- }
- }
- param {
- name: "r_hh2"
- init {
- type: kUniform
- low: -0.08
- high: 0.08
- }
- }
- param {
- name: "c_hh2"
- init {
- type: kUniform
- low: -0.08
- high: 0.08
- }
- }
- }
-
-
- layer {
- name: "ip1"
- type: kInnerProduct
- srclayers: "gru2"
- innerproduct_conf {
- num_output: 101
- }
- param {
- name: "w"
- init {
- type: kUniform
- low: -0.08
- high: 0.08
- }
- }
- param {
- name: "b"
- init {
- type: kUniform
- low: -0.08
- high: 0.08
- }
- }
- }
- layer {
- name: "softmax"
- type: kSoftmax
- srclayers: "ip1"
- }
- layer {
- name: "argsort"
- type: kArgSort
- srclayers: "softmax"
- }
- layer {
- name: "sampling"
- type: kCharRNNOutput
- srclayers: "argsort"
- char_rnn_conf {
- vocab_path: "examples/char-rnn/vocab.txt"
- }
- }
-}
-
-cluster {
- workspace: "examples/char-rnn/"
-}
http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/dd1e4afa/examples/cifar10/Makefile.example
----------------------------------------------------------------------
diff --git a/examples/cifar10/Makefile.example b/examples/cifar10/Makefile.example
deleted file mode 100644
index 40e85b1..0000000
--- a/examples/cifar10/Makefile.example
+++ /dev/null
@@ -1,41 +0,0 @@
-#/**
-# * Licensed to the Apache Software Foundation (ASF) under one
-# * or more contributor license agreements. See the NOTICE file
-# * distributed with this work for additional information
-# * regarding copyright ownership. The ASF licenses this file
-# * to you under the Apache License, Version 2.0 (the
-# * "License"); you may not use this file except in compliance
-# * with the License. You may obtain a copy of the License at
-# *
-# * http://www.apache.org/licenses/LICENSE-2.0
-# *
-# * Unless required by applicable law or agreed to in writing, software
-# * distributed under the License is distributed on an "AS IS" BASIS,
-# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# * See the License for the specific language governing permissions and
-# * limitations under the License.
-# */
-
-libs :=singa glog protobuf
-
-.PHONY: all download create
-
-HDFS_DIR := hdfs://node0:9000/examples/cifar10
-
-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_data.cc -std=c++11 -lsinga -lprotobuf -lglog \
- -I../../include -L../../.libs/ -Wl,-unresolved-symbols=ignore-in-shared-libs \
- -Wl,-rpath=../../.libs/ -o create_data.bin
- ./create_data.bin cifar-10-batches-bin .
-
-create_hdfs:
- $(CXX) create_data.cc -std=c++11 -lsinga -lprotobuf -lglog -lhdfs3 \
- -I../../include -L../../.libs/ -Wl,-unresolved-symbols=ignore-in-shared-libs \
- -Wl,-rpath=../../.libs/ -o create_data.bin
- ./create_data.bin cifar-10-batches-bin $(HDFS_DIR)
http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/dd1e4afa/examples/cifar10/create_data.cc
----------------------------------------------------------------------
diff --git a/examples/cifar10/create_data.cc b/examples/cifar10/create_data.cc
deleted file mode 100644
index 5564c38..0000000
--- a/examples/cifar10/create_data.cc
+++ /dev/null
@@ -1,138 +0,0 @@
-/************************************************************
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*************************************************************/
-
-
-/**
- * Create training and test DataShard for CIFAR dataset.
- * It is adapted from convert_cifar_data from Caffe.
- * create_shard.bin <input> <output_folder>
- *
- * Read from JobConf object the option to use KVfile, HDFS or other (1st layer
- * store_conf object).
- * To load to HDFS, specify "hdfs://namenode/examples" as the output folder
- */
-
-#include <glog/logging.h>
-#include <fstream>
-#include <string>
-#include <cstdint>
-#include <iostream>
-
-#include "singa/io/store.h"
-#include "singa/proto/common.pb.h"
-#include "singa/utils/common.h"
-
-using std::string;
-
-const int kCIFARSize = 32;
-const int kCIFARImageNBytes = 3072;
-const int kCIFARBatchSize = 10000;
-const int kCIFARTrainBatches = 5;
-
-void read_image(std::ifstream* file, int* label, char* buffer) {
- char label_char;
- file->read(&label_char, 1);
- *label = label_char;
- file->read(buffer, kCIFARImageNBytes);
- return;
-}
-
-void create_data(const string& input_folder, const string& output_folder) {
- int label;
- char str_buffer[kCIFARImageNBytes];
- string rec_buf;
- singa::RecordProto image;
- image.add_shape(3);
- image.add_shape(kCIFARSize);
- image.add_shape(kCIFARSize);
-
- singa::RecordProto mean;
- mean.CopyFrom(image);
- for (int i = 0; i < kCIFARImageNBytes; i++)
- mean.add_data(0.f);
-
- string store_backend = output_folder.find("hdfs") !=-1 ?
- "hdfsfile" : "kvfile";
- auto store = singa::io::CreateStore(store_backend);
- CHECK(store->Open(output_folder + "/train_data.bin", singa::io::kCreate));
- LOG(INFO) << "Preparing training data";
- int count = 0;
- for (int fileid = 0; fileid < kCIFARTrainBatches; ++fileid) {
- LOG(INFO) << "Training Batch " << fileid + 1;
- snprintf(str_buffer, kCIFARImageNBytes, "/data_batch_%d.bin", fileid + 1);
- std::ifstream data_file((input_folder + str_buffer).c_str(),
- std::ios::in | std::ios::binary);
- CHECK(data_file.is_open()) << "Unable to open train file #" << fileid + 1;
- for (int itemid = 0; itemid < kCIFARBatchSize; ++itemid) {
- read_image(&data_file, &label, str_buffer);
- image.set_label(label);
- image.set_pixel(str_buffer, kCIFARImageNBytes);
- image.SerializeToString(&rec_buf);
- int length = snprintf(str_buffer, kCIFARImageNBytes, "%05d", count);
- CHECK(store->Write(string(str_buffer, length), rec_buf));
-
- const string& pixels = image.pixel();
- for (int i = 0; i < kCIFARImageNBytes; i++)
- mean.set_data(i, mean.data(i) + static_cast<uint8_t>(pixels[i]));
- count += 1;
- }
- }
- store->Flush();
- store->Close();
-
- LOG(INFO) << "Create image mean";
- store->Open(output_folder + "/image_mean.bin", singa::io::kCreate);
- for (int i = 0; i < kCIFARImageNBytes; i++)
- mean.set_data(i, mean.data(i) / count);
- mean.SerializeToString(&rec_buf);
- store->Write("mean", rec_buf);
- store->Flush();
- store->Close();
-
- LOG(INFO) << "Create test data";
- store->Open(output_folder + "/test_data.bin", singa::io::kCreate);
- std::ifstream data_file((input_folder + "/test_batch.bin").c_str(),
- std::ios::in | std::ios::binary);
- CHECK(data_file.is_open()) << "Unable to open test file.";
- for (int itemid = 0; itemid < kCIFARBatchSize; ++itemid) {
- read_image(&data_file, &label, str_buffer);
- image.set_label(label);
- image.set_pixel(str_buffer, kCIFARImageNBytes);
- image.SerializeToString(&rec_buf);
- int length = snprintf(str_buffer, kCIFARImageNBytes, "%05d", itemid);
- CHECK(store->Write(string(str_buffer, length), rec_buf));
- }
- store->Flush();
- store->Close();
-}
-
-int main(int argc, char** argv) {
- if (argc != 3) {
- std::cout <<"Create train and test DataShard for Cifar dataset.\n"
- << "Usage:\n"
- << " create_data.bin input_folder output_folder\n"
- << "Where the input folder should contain the binary batch files.\n";
- } else {
- google::InitGoogleLogging(argv[0]);
- create_data(string(argv[1]), string(argv[2]));
- }
- return 0;
-}
http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/dd1e4afa/examples/cifar10/cudnn.conf
----------------------------------------------------------------------
diff --git a/examples/cifar10/cudnn.conf b/examples/cifar10/cudnn.conf
deleted file mode 100644
index 0f9402e..0000000
--- a/examples/cifar10/cudnn.conf
+++ /dev/null
@@ -1,297 +0,0 @@
-name: "cifar10-convnet"
-train_steps: 70000
-test_steps: 100
-test_freq: 1000
-#validate_steps: 100
-#validate_freq: 300
-disp_freq: 200
-gpu: 0
-#checkpoint_path: "examples/cifar10/checkpoint/step1000-worker0"
-train_one_batch {
- alg: kBP
-}
-updater{
- type: kSGD
- weight_decay:0.004
- momentum:0.9
- learning_rate {
- type: kFixedStep
- fixedstep_conf:{
- step:0
- step:60000
- step:65000
- step_lr:0.001
- step_lr:0.0001
- step_lr:0.00001
- }
- }
-}
-neuralnet {
- layer{
- name: "data"
- type: kRecordInput
- store_conf {
- backend: "kvfile"
- path: "examples/cifar10/train_data.bin"
- mean_file: "examples/cifar10/image_mean.bin"
- batchsize: 100
- #random_skip: 5000
- shape: 3
- shape: 32
- shape: 32
- }
- include: kTrain
- }
-# layer{
-# name: "data"
-# type: kRecordInput
-# store_conf {
-# backend: "kvfile"
-# path: "examples/cifar10/val_data.bin"
-# mean_file: "examples/cifar10/image_mean.bin"
-# batchsize: 64
-# random_skip: 5000
-# shape: 3
-# shape: 32
-# shape: 32
-# }
-# include: kVal
-# }
- layer{
- name: "data"
- type: kRecordInput
- store_conf {
- backend: "kvfile"
- path: "examples/cifar10/test_data.bin"
- mean_file: "examples/cifar10/image_mean.bin"
- batchsize: 100
- shape: 3
- shape: 32
- shape: 32
- }
- include: kTest
- }
-
- layer {
- name: "conv1"
- type: kCudnnConv
- srclayers: "data"
- convolution_conf {
- num_filters: 32
- kernel: 5
- stride: 1
- pad:2
- }
- param {
- name: "w1"
- init {
- type:kGaussian
- std:0.0001
- }
- }
- param {
- name: "b1"
- lr_scale:2.0
- wd_scale: 0
- init {
- type: kConstant
- value:0
- }
- }
- }
-
- layer {
- name: "pool1"
- type: kCudnnPool
- srclayers: "conv1"
- pooling_conf {
- pool: MAX
- kernel: 3
- stride: 2
- }
- }
- layer {
- name: "relu1"
- type: kCudnnActivation
- activation_conf {
- type: RELU
- }
- share_src_blobs: true
- srclayers:"pool1"
- }
- layer {
- name: "norm1"
- type: kCudnnLRN
- lrn_conf {
- local_size: 3
- alpha: 5e-05
- beta: 0.75
- }
- srclayers:"relu1"
- }
- layer {
- name: "conv2"
- type: kCudnnConv
- srclayers: "norm1"
- convolution_conf {
- num_filters: 32
- kernel: 5
- stride: 1
- pad:2
- }
- param {
- name: "w2"
- init {
- type:kGaussian
- std:0.01
- }
- }
- param {
- name: "b2"
- lr_scale:2.0
- wd_scale: 0
- init {
- type: kConstant
- value:0
- }
- }
- }
- layer {
- name: "relu2"
- type: kCudnnActivation
- activation_conf {
- type: RELU
- }
- share_src_blobs: true
- srclayers:"conv2"
- }
- layer {
- name: "pool2"
- type: kCudnnPool
- srclayers: "relu2"
- pooling_conf {
- pool: AVG
- kernel: 3
- stride: 2
- }
- }
- layer {
- name: "norm2"
- type: kCudnnLRN
- lrn_conf {
- local_size: 3
- alpha: 5e-05
- beta: 0.75
- }
- srclayers:"pool2"
- }
- layer {
- name: "conv3"
- type: kCudnnConv
- srclayers: "norm2"
- convolution_conf {
- num_filters: 64
- kernel: 5
- stride: 1
- pad:2
- }
- param {
- name: "w3"
- init {
- type:kGaussian
- std:0.01
- }
- }
- param {
- name: "b3"
- lr_scale: 2
- wd_scale: 0
- init {
- type: kConstant
- value:0
- }
- }
- }
- layer {
- name: "relu3"
- type: kCudnnActivation
- activation_conf {
- type: RELU
- }
- share_src_blobs: true
- srclayers:"conv3"
- }
- layer {
- name: "pool3"
- type: kCudnnPool
- srclayers: "relu3"
- pooling_conf {
- pool: AVG
- kernel: 3
- stride: 2
- }
- }
- layer {
- name: "ip1"
- type: kInnerProduct
- srclayers:"pool3"
- innerproduct_conf {
- num_output: 10
- }
- param {
- name: "w4"
- wd_scale:250
- init {
- type:kGaussian
- std:0.01
- }
- }
- param {
- name: "b4"
- lr_scale:2.0
- wd_scale:0
- init {
- type: kConstant
- value:0
- }
- }
- }
- layer {
- name : "softmax"
- type: kCudnnSoftmax
- srclayers: "ip1"
- include: kTest
- }
-
- layer {
- name : "accuracy"
- type: kAccuracy
- srclayers: "softmax"
- srclayers: "data"
- include: kTest
- }
- layer{
- name: "loss"
- type: kSoftmaxLoss
- srclayers:"ip1"
- srclayers: "data"
- include : kTrain
- }
-# uncomment "softmax", "argsort", "output" layer and comment "loss" layer
-# to extract features from argsort
-# layer {
-# name : "output"
-# type: kCSVOutput
-# srclayers: "argsort"
-# store_conf {
-# path: "examples/cifar10/out.csv"
-# }
-# }
-}
-cluster {
- nworker_groups: 1
- nserver_groups: 1
- nworkers_per_group: 1
- nworkers_per_procs: 1
- workspace: "examples/cifar10"
-}
http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/dd1e4afa/examples/cifar10/cudnn_bm.conf
----------------------------------------------------------------------
diff --git a/examples/cifar10/cudnn_bm.conf b/examples/cifar10/cudnn_bm.conf
deleted file mode 100644
index 2ca30cb..0000000
--- a/examples/cifar10/cudnn_bm.conf
+++ /dev/null
@@ -1,376 +0,0 @@
-name: "cifar10-convnet"
-train_steps: 70000
-test_steps: 100
-test_freq: 1000
-#validate_steps: 100
-#validate_freq: 300
-disp_freq: 200
-gpu: 0
-#checkpoint_path: "examples/cifar10/checkpoint/step1000-worker0"
-train_one_batch {
- alg: kBP
-}
-updater{
- type: kSGD
- weight_decay:0.004
- momentum:0.9
- learning_rate {
- type: kFixedStep
- fixedstep_conf:{
- step:0
- step:60000
- step:65000
- step_lr:0.001
- step_lr:0.0001
- step_lr:0.00001
- }
- }
-}
-neuralnet {
- layer{
- name: "data"
- type: kRecordInput
- store_conf {
- backend: "kvfile"
- path: "examples/cifar10/train_data.bin"
- mean_file: "examples/cifar10/image_mean.bin"
- batchsize: 100
- #random_skip: 5000
- shape: 3
- shape: 32
- shape: 32
- }
- include: kTrain
- }
-# layer{
-# name: "data"
-# type: kRecordInput
-# store_conf {
-# backend: "kvfile"
-# path: "examples/cifar10/val_data.bin"
-# mean_file: "examples/cifar10/image_mean.bin"
-# batchsize: 64
-# random_skip: 5000
-# shape: 3
-# shape: 32
-# shape: 32
-# }
-# include: kVal
-# }
- layer{
- name: "data"
- type: kRecordInput
- store_conf {
- backend: "kvfile"
- path: "examples/cifar10/test_data.bin"
- mean_file: "examples/cifar10/image_mean.bin"
- batchsize: 100
- shape: 3
- shape: 32
- shape: 32
- }
- include: kTest
- }
-
- layer {
- name: "conv1"
- type: kCudnnConv
- srclayers: "data"
- convolution_conf {
- num_filters: 32
- kernel: 5
- stride: 1
- pad:2
- }
- param {
- name: "w1"
- init {
- type:kGaussian
- std:0.0001
- }
- }
- param {
- name: "b1"
- lr_scale:2.0
- wd_scale: 0
- init {
- type: kConstant
- value:0
- }
- }
- }
-
- layer {
- name: "pool1"
- type: kCudnnPool
- srclayers: "conv1"
- pooling_conf {
- pool: MAX
- kernel: 3
- stride: 2
- }
- }
- layer {
- name: "bm1"
- type: kCudnnBM
- param {
- name: "s11"
- init {
- type:kConstant
- value:1
- }
- }
- param {
- name: "s12"
- init {
- type:kConstant
- value:0
- }
- }
- param {
- name: "s13"
- init {
- type:kConstant
- value:0
- }
- }
- param {
- name: "s14"
- init {
- type:kConstant
- value:0
- }
- }
- srclayers:"pool1"
- }
- layer {
- name: "relu1"
- type: kCudnnActivation
- activation_conf {
- type: RELU
- }
- share_src_blobs: true
- srclayers:"bm1"
- }
- layer {
- name: "conv2"
- type: kCudnnConv
- srclayers: "relu1"
- convolution_conf {
- num_filters: 32
- kernel: 5
- stride: 1
- pad:2
- }
- param {
- name: "w2"
- init {
- type:kGaussian
- std:0.01
- }
- }
- param {
- name: "b2"
- lr_scale:2.0
- wd_scale: 0
- init {
- type: kConstant
- value:0
- }
- }
- }
- layer {
- name: "bm2"
- type: kCudnnBM
- param {
- name: "s21"
- init {
- type:kConstant
- value:1
- }
- }
- param {
- name: "s22"
- init {
- type:kConstant
- value:0
- }
- }
- param {
- name: "s23"
- init {
- type:kConstant
- value:0
- }
- }
- param {
- name: "s24"
- init {
- type:kConstant
- value:0
- }
- }
- srclayers:"conv2"
- }
- layer {
- name: "relu2"
- type: kCudnnActivation
- activation_conf {
- type: RELU
- }
- share_src_blobs: true
- srclayers:"bm2"
- }
- layer {
- name: "pool2"
- type: kCudnnPool
- srclayers: "relu2"
- pooling_conf {
- pool: AVG
- kernel: 3
- stride: 2
- }
- }
- layer {
- name: "conv3"
- type: kCudnnConv
- srclayers: "relu2"
- convolution_conf {
- num_filters: 64
- kernel: 5
- stride: 1
- pad:2
- }
- param {
- name: "w3"
- init {
- type:kGaussian
- std:0.01
- }
- }
- param {
- name: "b3"
- lr_scale: 2
- wd_scale: 0
- init {
- type: kConstant
- value:0
- }
- }
- }
- layer {
- name: "bm3"
- type: kCudnnBM
- param {
- name: "s31"
- init {
- type:kConstant
- value:1
- }
- }
- param {
- name: "s32"
- init {
- type:kConstant
- value:0
- }
- }
- param {
- name: "s33"
- init {
- type:kConstant
- value:0
- }
- }
- param {
- name: "s34"
- init {
- type:kConstant
- value:0
- }
- }
- srclayers:"conv3"
- }
- layer {
- name: "relu3"
- type: kCudnnActivation
- activation_conf {
- type: RELU
- }
- share_src_blobs: true
- srclayers:"bm3"
- }
- layer {
- name: "pool3"
- type: kCudnnPool
- srclayers: "relu3"
- pooling_conf {
- pool: AVG
- kernel: 3
- stride: 2
- }
- }
- layer {
- name: "ip1"
- type: kInnerProduct
- srclayers:"pool3"
- innerproduct_conf {
- num_output: 10
- }
- param {
- name: "w4"
- wd_scale:250
- init {
- type:kGaussian
- std:0.01
- }
- }
- param {
- name: "b4"
- lr_scale:2.0
- wd_scale:0
- init {
- type: kConstant
- value:0
- }
- }
- }
- layer {
- name : "softmax"
- type: kCudnnSoftmax
- srclayers: "ip1"
- include: kTest
- }
-
- layer {
- name : "accuracy"
- type: kAccuracy
- srclayers: "softmax"
- srclayers: "data"
- include: kTest
- }
- layer{
- name: "loss"
- type: kSoftmaxLoss
- srclayers:"ip1"
- srclayers: "data"
- include : kTrain
- }
-# uncomment "softmax", "argsort", "output" layer and comment "loss" layer
-# to extract features from argsort
-# layer {
-# name : "output"
-# type: kCSVOutput
-# srclayers: "argsort"
-# store_conf {
-# path: "examples/cifar10/out.csv"
-# }
-# }
-}
-cluster {
- nworker_groups: 1
- nserver_groups: 1
- nworkers_per_group: 1
- nworkers_per_procs: 1
- workspace: "examples/cifar10"
-}
http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/dd1e4afa/examples/cifar10/cudnn_hybrid.conf
----------------------------------------------------------------------
diff --git a/examples/cifar10/cudnn_hybrid.conf b/examples/cifar10/cudnn_hybrid.conf
deleted file mode 100644
index a11145c..0000000
--- a/examples/cifar10/cudnn_hybrid.conf
+++ /dev/null
@@ -1,306 +0,0 @@
-name: "cifar10-convnet"
-train_steps: 10000
-test_steps: 0
-test_freq: 200
-#validate_steps: 100
-#validate_freq: 300
-disp_freq: 200
-gpu: 0
-gpu: 1
-#debug: true
-#checkpoint_path: "examples/cifar10/checkpoint/step1000-worker0"
-train_one_batch {
- alg: kBP
-}
-updater{
- type: kSGD
- weight_decay:0.004
- momentum:0.9
- learning_rate {
- type: kFixedStep
- fixedstep_conf:{
- step:0
- step:60000
- step:65000
- step_lr:0.001
- step_lr:0.0001
- step_lr:0.00001
- }
- }
-}
-neuralnet {
- layer{
- name: "data"
- type: kRecordInput
- store_conf {
- backend: "kvfile"
- path: "examples/cifar10/train_data.bin"
- mean_file: "examples/cifar10/image_mean.bin"
- batchsize: 100
- #random_skip: 5000
- shape: 3
- shape: 32
- shape: 32
- }
- include: kTrain
- partition_dim: 0
- }
-# layer{
-# name: "data"
-# type: kRecordInput
-# store_conf {
-# backend: "kvfile"
-# path: "examples/cifar10/val_data.bin"
-# mean_file: "examples/cifar10/image_mean.bin"
-# batchsize: 64
-# random_skip: 5000
-# shape: 3
-# shape: 32
-# shape: 32
-# }
-# include: kVal
-# }
- layer{
- name: "data"
- type: kRecordInput
- store_conf {
- backend: "kvfile"
- path: "examples/cifar10/test_data.bin"
- mean_file: "examples/cifar10/image_mean.bin"
- batchsize: 100
- shape: 3
- shape: 32
- shape: 32
- }
- include: kTest
- partition_dim: 0
- }
-
- layer {
- partition_dim: 0
- name: "conv1"
- type: kCudnnConv
- srclayers: "data"
- convolution_conf {
- num_filters: 32
- kernel: 5
- stride: 1
- pad:2
- }
- param {
- name: "w1"
- init {
- type:kGaussian
- std:0.0001
- }
- }
- param {
- name: "b1"
- lr_scale:2.0
- init {
- type: kConstant
- value:0
- }
- }
- }
-
- layer {
- partition_dim: 0
- name: "pool1"
- type: kCudnnPool
- srclayers: "conv1"
- pooling_conf {
- pool: MAX
- kernel: 3
- stride: 2
- }
- }
- layer {
- partition_dim: 0
- name: "relu1"
- type: kCudnnActivation
- activation_conf {
- type: RELU
- }
- srclayers:"pool1"
- }
- layer {
- partition_dim: 0
- name: "norm1"
- type: kCudnnLRN
- lrn_conf {
- local_size: 3
- alpha: 5e-05
- beta: 0.75
- }
- srclayers:"relu1"
- }
- layer {
- partition_dim: 0
- name: "conv2"
- type: kCudnnConv
- srclayers: "norm1"
- convolution_conf {
- num_filters: 32
- kernel: 5
- stride: 1
- pad:2
- }
- param {
- name: "w2"
- init {
- type:kGaussian
- std:0.01
- }
- }
- param {
- name: "b2"
- lr_scale:2.0
- init {
- type: kConstant
- value:0
- }
- }
- }
- layer {
- partition_dim: 0
- name: "relu2"
- type: kCudnnActivation
- activation_conf {
- type: RELU
- }
- srclayers:"conv2"
- }
- layer {
- partition_dim: 0
- name: "pool2"
- type: kCudnnPool
- srclayers: "relu2"
- pooling_conf {
- pool: AVG
- kernel: 3
- stride: 2
- }
- }
- layer {
- partition_dim: 0
- name: "norm2"
- type: kCudnnLRN
- lrn_conf {
- local_size: 3
- alpha: 5e-05
- beta: 0.75
- }
- srclayers:"pool2"
- }
- layer {
- partition_dim: 0
- name: "conv3"
- type: kCudnnConv
- srclayers: "norm2"
- convolution_conf {
- num_filters: 64
- kernel: 5
- stride: 1
- pad:2
- }
- param {
- name: "w3"
- init {
- type:kGaussian
- std:0.01
- }
- }
- param {
- name: "b3"
- init {
- type: kConstant
- value:0
- }
- }
- }
- layer {
- partition_dim: 0
- name: "relu3"
- type: kCudnnActivation
- activation_conf {
- type: RELU
- }
- srclayers:"conv3"
- }
- layer {
- partition_dim: 0
- name: "pool3"
- type: kCudnnPool
- srclayers: "relu3"
- pooling_conf {
- pool: AVG
- kernel: 3
- stride: 2
- }
- }
- layer {
- partition_dim: 1
- name: "ip1"
- type: kInnerProduct
- srclayers:"pool3"
- innerproduct_conf {
- num_output: 10
- }
- param {
- name: "w4"
- wd_scale:250
- init {
- type:kGaussian
- std:0.01
- }
- }
- param {
- name: "b4"
- lr_scale:2.0
- wd_scale:0
- init {
- type: kConstant
- value:0
- }
- }
- }
-# layer {
-# name : "softmax"
-# type: kSoftmax
-# srclayers: "ip1"
-# }
-#
-# layer {
-# name : "argsort"
-# type: kArgSort
-# srclayers: "softmax"
-# }
- layer{
- partition_dim: 0
- name: "loss"
- type: kSoftmaxLoss
- softmaxloss_conf{
- topk:1
- }
- srclayers:"ip1"
- srclayers: "data"
- }
-# uncomment "softmax", "argsort", "output" layer and comment "loss" layer
-# to extract features from argsort
-# layer {
-# name : "output"
-# type: kCSVOutput
-# srclayers: "argsort"
-# store_conf {
-# path: "examples/cifar10/out.csv"
-# }
-# }
-}
-cluster {
- nworker_groups: 1
- nserver_groups: 1
- nworkers_per_group: 2
- nworkers_per_procs: 2
- workspace: "examples/cifar10"
-}
http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/dd1e4afa/examples/cifar10/hybrid.conf
----------------------------------------------------------------------
diff --git a/examples/cifar10/hybrid.conf b/examples/cifar10/hybrid.conf
deleted file mode 100644
index ec3da0c..0000000
--- a/examples/cifar10/hybrid.conf
+++ /dev/null
@@ -1,292 +0,0 @@
-name: "cifar10-convnet"
-train_steps: 1000
-test_steps: 0
-test_freq: 200
-#validate_steps: 100
-#validate_freq: 300
-disp_freq: 30
-#debug: true
-#checkpoint_path: "examples/cifar10/checkpoint/step1000-worker0"
-train_one_batch {
- alg: kBP
-}
-updater{
- type: kSGD
- weight_decay:0.004
- momentum:0.9
- learning_rate {
- type: kFixedStep
- fixedstep_conf:{
- step:0
- step:60000
- step:65000
- step_lr:0.001
- step_lr:0.0001
- step_lr:0.00001
- }
- }
-}
-neuralnet {
- layer{
- name: "data"
- type: kRecordInput
- store_conf {
- backend: "kvfile"
- path: "examples/cifar10/train_data.bin"
- mean_file: "examples/cifar10/image_mean.bin"
- batchsize: 100
- #random_skip: 5000
- shape: 3
- shape: 32
- shape: 32
- }
- include: kTrain
- }
-# layer{
-# name: "data"
-# type: kRecordInput
-# store_conf {
-# backend: "kvfile"
-# path: "examples/cifar10/val_data.bin"
-# mean_file: "examples/cifar10/image_mean.bin"
-# batchsize: 64
-# random_skip: 5000
-# shape: 3
-# shape: 32
-# shape: 32
-# }
-# include: kVal
-# }
- layer{
- name: "data"
- type: kRecordInput
- store_conf {
- backend: "kvfile"
- path: "examples/cifar10/test_data.bin"
- mean_file: "examples/cifar10/image_mean.bin"
- batchsize: 100
- shape: 3
- shape: 32
- shape: 32
- }
- include: kTest
- }
-
- layer {
- partition_dim: 0
- name: "conv1"
- type: kCConvolution
- srclayers: "data"
- convolution_conf {
- num_filters: 32
- kernel: 5
- stride: 1
- pad:2
- }
- param {
- name: "w1"
- init {
- type:kGaussian
- std:0.0001
- }
- }
- param {
- name: "b1"
- lr_scale:2.0
- init {
- type: kConstant
- value:0
- }
- }
- }
-
- layer {
- partition_dim: 0
- name: "pool1"
- type: kCPooling
- srclayers: "conv1"
- pooling_conf {
- pool: MAX
- kernel: 3
- stride: 2
- }
- }
- layer {
- partition_dim: 0
- name: "relu1"
- type: kReLU
- srclayers:"pool1"
- }
- layer {
- partition_dim: 0
- name: "norm1"
- type: kLRN
- lrn_conf {
- local_size: 3
- alpha: 5e-05
- beta: 0.75
- }
- srclayers:"relu1"
- }
- layer {
- partition_dim: 0
- name: "conv2"
- type: kCConvolution
- srclayers: "norm1"
- convolution_conf {
- num_filters: 32
- kernel: 5
- stride: 1
- pad:2
- }
- param {
- name: "w2"
- init {
- type:kGaussian
- std:0.01
- }
- }
- param {
- name: "b2"
- lr_scale:2.0
- init {
- type: kConstant
- value:0
- }
- }
- }
- layer {
- partition_dim: 0
- name: "relu2"
- type: kReLU
- srclayers:"conv2"
- }
- layer {
- partition_dim: 0
- name: "pool2"
- type: kCPooling
- srclayers: "relu2"
- pooling_conf {
- pool: AVG
- kernel: 3
- stride: 2
- }
- }
- layer {
- partition_dim: 0
- name: "norm2"
- type: kLRN
- lrn_conf {
- local_size: 3
- alpha: 5e-05
- beta: 0.75
- }
- srclayers:"pool2"
- }
- layer {
- partition_dim: 0
- name: "conv3"
- type: kCConvolution
- srclayers: "norm2"
- convolution_conf {
- num_filters: 64
- kernel: 5
- stride: 1
- pad:2
- }
- param {
- name: "w3"
- init {
- type:kGaussian
- std:0.01
- }
- }
- param {
- name: "b3"
- init {
- type: kConstant
- value:0
- }
- }
- }
- layer {
- partition_dim: 0
- name: "relu3"
- type: kReLU
- srclayers:"conv3"
- }
- layer {
- partition_dim: 0
- name: "pool3"
- type: kCPooling
- srclayers: "relu3"
- pooling_conf {
- pool: AVG
- kernel: 3
- stride: 2
- }
- }
- layer {
- partition_dim: 1
- name: "ip1"
- type: kInnerProduct
- srclayers:"pool3"
- innerproduct_conf {
- num_output: 10
- }
- param {
- name: "w4"
- wd_scale:250
- init {
- type:kGaussian
- std:0.01
- }
- }
- param {
- name: "b4"
- lr_scale:2.0
- wd_scale:0
- init {
- type: kConstant
- value:0
- }
- }
- }
-# layer {
-# name : "softmax"
-# type: kSoftmax
-# srclayers: "ip1"
-# }
-#
-# layer {
-# name : "argsort"
-# type: kArgSort
-# srclayers: "softmax"
-# }
- layer{
- name: "loss"
- type: kSoftmaxLoss
- softmaxloss_conf{
- topk:1
- }
- srclayers:"ip1"
- srclayers: "data"
- }
-# uncomment "softmax", "argsort", "output" layer and comment "loss" layer
-# to extract features from argsort
-# layer {
-# name : "output"
-# type: kCSVOutput
-# srclayers: "argsort"
-# store_conf {
-# path: "examples/cifar10/out.csv"
-# }
-# }
-}
-cluster {
- nworker_groups: 1
- nserver_groups: 1
- nworkers_per_group: 2
- nworkers_per_procs: 2
- workspace: "examples/cifar10"
-}
http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/dd1e4afa/examples/cifar10/job.conf
----------------------------------------------------------------------
diff --git a/examples/cifar10/job.conf b/examples/cifar10/job.conf
deleted file mode 100644
index d20b452..0000000
--- a/examples/cifar10/job.conf
+++ /dev/null
@@ -1,279 +0,0 @@
-name: "cifar10-convnet"
-train_steps: 1000
-test_steps: 100
-test_freq: 200
-#validate_steps: 100
-#validate_freq: 300
-disp_freq: 50
-#checkpoint_path: "examples/cifar10/checkpoint/step1000-worker0"
-train_one_batch {
- alg: kBP
-}
-updater{
- type: kSGD
- weight_decay:0.004
- momentum:0.9
- learning_rate {
- type: kFixedStep
- fixedstep_conf:{
- step:0
- step:60000
- step:65000
- step_lr:0.001
- step_lr:0.0001
- step_lr:0.00001
- }
- }
-}
-neuralnet {
- layer{
- name: "data"
- type: kRecordInput
- store_conf {
- backend: "kvfile"
- path: "examples/cifar10/train_data.bin"
- mean_file: "examples/cifar10/image_mean.bin"
- batchsize: 100
- #random_skip: 5000
- shape: 3
- shape: 32
- shape: 32
- }
- include: kTrain
- }
-# layer{
-# name: "data"
-# type: kRecordInput
-# store_conf {
-# backend: "kvfile"
-# path: "examples/cifar10/val_data.bin"
-# mean_file: "examples/cifar10/image_mean.bin"
-# batchsize: 64
-# random_skip: 5000
-# shape: 3
-# shape: 32
-# shape: 32
-# }
-# include: kVal
-# }
- layer{
- name: "data"
- type: kRecordInput
- store_conf {
- backend: "kvfile"
- path: "examples/cifar10/test_data.bin"
- mean_file: "examples/cifar10/image_mean.bin"
- batchsize: 100
- shape: 3
- shape: 32
- shape: 32
- }
- include: kTest
- }
-
- layer {
- name: "conv1"
- type: kCConvolution
- srclayers: "data"
- convolution_conf {
- num_filters: 32
- kernel: 5
- stride: 1
- pad:2
- }
- param {
- name: "w1"
- init {
- type:kGaussian
- std:0.0001
- }
- }
- param {
- name: "b1"
- lr_scale:2.0
- init {
- type: kConstant
- value:0
- }
- }
- }
-
- layer {
- name: "pool1"
- type: kCPooling
- srclayers: "conv1"
- pooling_conf {
- pool: MAX
- kernel: 3
- stride: 2
- }
- }
- layer {
- name: "relu1"
- type: kReLU
- srclayers:"pool1"
- }
- layer {
- name: "norm1"
- type: kLRN
- lrn_conf {
- local_size: 3
- alpha: 5e-05
- beta: 0.75
- }
- srclayers:"relu1"
- }
- layer {
- name: "conv2"
- type: kCConvolution
- srclayers: "norm1"
- convolution_conf {
- num_filters: 32
- kernel: 5
- stride: 1
- pad:2
- }
- param {
- name: "w2"
- init {
- type:kGaussian
- std:0.01
- }
- }
- param {
- name: "b2"
- lr_scale:2.0
- init {
- type: kConstant
- value:0
- }
- }
- }
- layer {
- name: "relu2"
- type: kReLU
- srclayers:"conv2"
- }
- layer {
- name: "pool2"
- type: kCPooling
- srclayers: "relu2"
- pooling_conf {
- pool: AVG
- kernel: 3
- stride: 2
- }
- }
- layer {
- name: "norm2"
- type: kLRN
- lrn_conf {
- local_size: 3
- alpha: 5e-05
- beta: 0.75
- }
- srclayers:"pool2"
- }
- layer {
- name: "conv3"
- type: kCConvolution
- srclayers: "norm2"
- convolution_conf {
- num_filters: 64
- kernel: 5
- stride: 1
- pad:2
- }
- param {
- name: "w3"
- init {
- type:kGaussian
- std:0.01
- }
- }
- param {
- name: "b3"
- init {
- type: kConstant
- value:0
- }
- }
- }
- layer {
- name: "relu3"
- type: kReLU
- srclayers:"conv3"
- }
- layer {
- name: "pool3"
- type: kCPooling
- srclayers: "relu3"
- pooling_conf {
- pool: AVG
- kernel: 3
- stride: 2
- }
- }
- layer {
- name: "ip1"
- type: kInnerProduct
- srclayers:"pool3"
- innerproduct_conf {
- num_output: 10
- }
- param {
- name: "w4"
- wd_scale:250
- init {
- type:kGaussian
- std:0.01
- }
- }
- param {
- name: "b4"
- lr_scale:2.0
- wd_scale:0
- init {
- type: kConstant
- value:0
- }
- }
- }
-# layer {
-# name : "softmax"
-# type: kSoftmax
-# srclayers: "ip1"
-# }
-#
-# layer {
-# name : "argsort"
-# type: kArgSort
-# srclayers: "softmax"
-# }
- layer{
- name: "loss"
- type: kSoftmaxLoss
- softmaxloss_conf{
- topk:1
- }
- srclayers:"ip1"
- srclayers: "data"
- }
-# uncomment "softmax", "argsort", "output" layer and comment "loss" layer
-# to extract features from argsort
-# layer {
-# name : "output"
-# type: kCSVOutput
-# srclayers: "argsort"
-# store_conf {
-# path: "examples/cifar10/out.csv"
-# }
-# }
-}
-cluster {
- nworker_groups: 1
- nserver_groups: 1
- nworkers_per_group: 1
- nworkers_per_procs: 1
- workspace: "examples/cifar10"
-}
http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/dd1e4afa/examples/mnist/Makefile.example
----------------------------------------------------------------------
diff --git a/examples/mnist/Makefile.example b/examples/mnist/Makefile.example
deleted file mode 100644
index a041359..0000000
--- a/examples/mnist/Makefile.example
+++ /dev/null
@@ -1,49 +0,0 @@
-#
-#/**
-# * Licensed to the Apache Software Foundation (ASF) under one
-# * or more contributor license agreements. See the NOTICE file
-# * distributed with this work for additional information
-# * regarding copyright ownership. The ASF licenses this file
-# * to you under the Apache License, Version 2.0 (the
-# * "License"); you may not use this file except in compliance
-# * with the License. You may obtain a copy of the License at
-# *
-# * http://www.apache.org/licenses/LICENSE-2.0
-# *
-# * Unless required by applicable law or agreed to in writing, software
-# * distributed under the License is distributed on an "AS IS" BASIS,
-# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# * See the License for the specific language governing permissions and
-# * limitations under the License.
-# */
-
-libs :=singa glog protobuf
-
-.PHONY: all download create
-
-HDFS_MNIST_TRAIN := hdfs://node0:9000/examples/mnist/train_data.bin
-HDFS_MNIST_TEST := hdfs://node0:9000/examples/mnist/test_data.bin
-
-download: mnist
-
-mnist:
- wget http://yann.lecun.com/exdb/mnist/train-images-idx3-ubyte.gz
- wget http://yann.lecun.com/exdb/mnist/train-labels-idx1-ubyte.gz
- wget http://yann.lecun.com/exdb/mnist/t10k-images-idx3-ubyte.gz
- wget http://yann.lecun.com/exdb/mnist/t10k-labels-idx1-ubyte.gz
- gunzip train-images-idx3-ubyte.gz && gunzip train-labels-idx1-ubyte.gz
- gunzip t10k-images-idx3-ubyte.gz && gunzip t10k-labels-idx1-ubyte.gz
-
-create:
- $(CXX) create_data.cc -std=c++11 -lsinga -lprotobuf -lglog -I../../include \
- -L../../.libs/ -Wl,-unresolved-symbols=ignore-in-shared-libs -Wl,-rpath=../../.libs/ \
- -o create_data.bin
- ./create_data.bin train-images-idx3-ubyte train-labels-idx1-ubyte train_data.bin
- ./create_data.bin t10k-images-idx3-ubyte t10k-labels-idx1-ubyte test_data.bin
-
-create_hdfs:
- $(CXX) create_data.cc -std=c++11 -lsinga -lprotobuf -lglog -lhdfs3 -I../../include \
- -L../../.libs/ -Wl,-unresolved-symbols=ignore-in-shared-libs -Wl,-rpath=../../.libs/ \
- -o create_data.bin
- ./create_data.bin train-images-idx3-ubyte train-labels-idx1-ubyte $(HDFS_MNIST_TRAIN)
- ./create_data.bin t10k-images-idx3-ubyte t10k-labels-idx1-ubyte $(HDFS_MNIST_TEST)
http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/dd1e4afa/examples/mnist/conv.conf
----------------------------------------------------------------------
diff --git a/examples/mnist/conv.conf b/examples/mnist/conv.conf
deleted file mode 100644
index 7818af1..0000000
--- a/examples/mnist/conv.conf
+++ /dev/null
@@ -1,187 +0,0 @@
-name: "conv"
-train_steps: 10000
-test_steps:100
-test_freq:500
-disp_freq:50
-train_one_batch {
- alg: kBP
-}
-updater {
- momentum:0.9
- weight_decay:0.0005
- type: kSGD
- learning_rate {
- type : kInverse
- base_lr:0.01
- inverse_conf {
- gamma:0.0001
- pow:0.75
- }
- }
-}
-neuralnet {
- layer {
- name: "data"
- type: kRecordInput
- store_conf {
- backend: "kvfile"
- path: "examples/mnist/train_data.bin"
- batchsize: 64
- std_value: 255
- random_skip: 5000
- shape: 1
- shape: 28
- shape: 28
- }
- include: kTrain
- }
-
- layer {
- name: "data"
- type: kRecordInput
- store_conf {
- backend: "kvfile"
- path: "examples/mnist/test_data.bin"
- std_value: 255
- batchsize: 100
- shape: 1
- shape: 28
- shape: 28
- }
- include: kTest
- }
-
- layer {
- name: "conv1"
- type: kCConvolution
- srclayers: "data"
- convolution_conf {
- num_filters: 20
- kernel: 5
- stride: 1
- }
- param{
- name: "w1"
- init {
- type : kUniformSqrtFanIn
- }
- }
- param{
- name: "b1"
- init {
- type : kConstant
- value:0
- }
- lr_scale:2.0
- }
- }
- layer {
- name: "pool1"
- type: kCPooling
- srclayers: "conv1"
- pooling_conf {
- pool: MAX
- kernel: 2
- stride: 2
- }
- }
- layer {
- name: "conv2"
- type: kCConvolution
- srclayers: "pool1"
- convolution_conf {
- num_filters: 50
- kernel: 5
- stride: 1
- }
- param{
- name: "w2"
- init {
- type :kUniformSqrtFanIn
- }
- }
- param{
- name: "b2"
- init {
- type : kConstant
- value:0
- }
- lr_scale:2.0
- }
- }
- layer {
- name: "pool2"
- type: kCPooling
- srclayers: "conv2"
- pooling_conf {
- pool: MAX
- kernel: 2
- stride: 2
- }
- }
- layer {
- name: "ip1"
- type: kInnerProduct
- srclayers:"pool2"
- innerproduct_conf {
- num_output: 500
- }
- param{
- name: "w3"
- init {
- type :kUniformSqrtFanIn
- }
- }
- param{
- name: "b3"
- init {
- type : kConstant
- value:0
- }
- lr_scale:2.0
- }
- }
-
- layer {
- name: "relu1"
- type: kReLU
- srclayers:"ip1"
- }
-
- layer {
- name: "ip2"
- type: kInnerProduct
- srclayers:"relu1"
- innerproduct_conf {
- num_output: 10
- }
- param {
- name: "w4"
- init {
- type :kUniformSqrtFanIn
- }
- }
- param {
- name: "b4"
- init {
- type : kConstant
- value:0
- }
- lr_scale:2
- }
- }
- layer{
- name: "loss"
- type: kSoftmaxLoss
- softmaxloss_conf{
- topk:1
- }
- srclayers:"ip2"
- srclayers:"data"
- }
-}
-cluster {
- nworker_groups: 1
- nserver_groups: 1
- workspace: "examples/mnist"
-}
http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/dd1e4afa/examples/mnist/create_data.cc
----------------------------------------------------------------------
diff --git a/examples/mnist/create_data.cc b/examples/mnist/create_data.cc
deleted file mode 100644
index 34c287f..0000000
--- a/examples/mnist/create_data.cc
+++ /dev/null
@@ -1,125 +0,0 @@
-/************************************************************
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*************************************************************/
-
-//
-// This code creates DataShard for MNIST dataset.
-// It is adapted from the convert_mnist_data from Caffe
-//
-// Usage:
-// create_shard.bin input_image_file input_label_file output_folder
-// The MNIST dataset could be downloaded at
-// http://yann.lecun.com/exdb/mnist/
-
-#include <glog/logging.h>
-#include <cstdint>
-#include <iostream>
-
-#include <fstream>
-#include <string>
-
-#include "singa/io/store.h"
-#include "singa/utils/common.h"
-#include "singa/proto/common.pb.h"
-
-using std::string;
-
-uint32_t swap_endian(uint32_t val) {
- val = ((val << 8) & 0xFF00FF00) | ((val >> 8) & 0xFF00FF);
- return (val << 16) | (val >> 16);
-}
-
-// output is the full path, unlike create_data in CIFAR with only
-// specifies the directory
-void create_data(const char* image_filename, const char* label_filename,
- const char* output) {
- // Open files
- std::ifstream image_file(image_filename, std::ios::in | std::ios::binary);
- std::ifstream label_file(label_filename, std::ios::in | std::ios::binary);
- CHECK(image_file) << "Unable to open file " << image_filename;
- CHECK(label_file) << "Unable to open file " << label_filename;
- // Read the magic and the meta data
- uint32_t magic;
- uint32_t num_items;
- uint32_t num_labels;
- uint32_t rows;
- uint32_t cols;
-
- image_file.read(reinterpret_cast<char*>(&magic), 4);
- magic = swap_endian(magic);
- CHECK_EQ(magic, 2051) << "Incorrect image file magic.";
- label_file.read(reinterpret_cast<char*>(&magic), 4);
- magic = swap_endian(magic);
- CHECK_EQ(magic, 2049) << "Incorrect label file magic.";
- image_file.read(reinterpret_cast<char*>(&num_items), 4);
- num_items = swap_endian(num_items);
- label_file.read(reinterpret_cast<char*>(&num_labels), 4);
- num_labels = swap_endian(num_labels);
- CHECK_EQ(num_items, num_labels);
- image_file.read(reinterpret_cast<char*>(&rows), 4);
- rows = swap_endian(rows);
- image_file.read(reinterpret_cast<char*>(&cols), 4);
- cols = swap_endian(cols);
-
- // read backend from the job.conf
- string store_backend = string(output).find("hdfs") != -1 ?
- "hdfsfile" : "kvfile";
- auto store = singa::io::OpenStore(store_backend, output, singa::io::kCreate);
- char label;
- char* pixels = new char[rows * cols];
- int count = 0;
- const int kMaxKeyLength = 10;
- char key[kMaxKeyLength];
- string value;
-
- singa::RecordProto image;
- image.add_shape(rows);
- image.add_shape(cols);
- LOG(INFO) << "A total of " << num_items << " items.";
- LOG(INFO) << "Rows: " << rows << " Cols: " << cols;
- for (int item_id = 0; item_id < num_items; ++item_id) {
- image_file.read(pixels, rows * cols);
- label_file.read(&label, 1);
- image.set_pixel(pixels, rows*cols);
- image.set_label(label);
- snprintf(key, kMaxKeyLength, "%08d", item_id);
- image.SerializeToString(&value);
- store->Write(string(key), value);
- }
- delete pixels;
- store->Flush();
- delete store;
-}
-
-int main(int argc, char** argv) {
- if (argc != 4) {
- std::cout << "This program create a DataShard for a MNIST dataset\n"
- "Usage:\n"
- " create_shard.bin input_image_file input_label_file"
- " output_db_file\n"
- "The MNIST dataset could be downloaded at\n"
- " http://yann.lecun.com/exdb/mnist/\n"
- "You should gunzip them after downloading.";
- } else {
- google::InitGoogleLogging(argv[0]);
- create_data(argv[1], argv[2], argv[3]);
- }
- return 0;
-}
http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/dd1e4afa/examples/mnist/job.conf
----------------------------------------------------------------------
diff --git a/examples/mnist/job.conf b/examples/mnist/job.conf
deleted file mode 100644
index 41d6b6f..0000000
--- a/examples/mnist/job.conf
+++ /dev/null
@@ -1,241 +0,0 @@
-name: "mlp"
-train_steps: 1000
-test_steps:10
-test_freq:60
-disp_freq:10
-train_one_batch {
- alg: kBP
-}
-updater{
- type: kSGD
- learning_rate{
- type : kStep
- base_lr: 0.001
- step_conf{
- change_freq: 60
- gamma: 0.997
- }
- }
-}
-
-neuralnet {
- layer {
- name: "data"
- type: kRecordInput
- store_conf {
- backend: "kvfile"
- path: "examples/mnist/train_data.bin"
- random_skip: 5000
- batchsize: 64
- shape: 784
- std_value: 127.5
- mean_value: 127.5
- }
- include: kTrain
- }
-
- layer {
- name: "data"
- type: kRecordInput
- store_conf {
- backend: "kvfile"
- path: "examples/mnist/test_data.bin"
- batchsize: 100
- shape: 784
- std_value: 127.5
- mean_value: 127.5
- }
- include: kTest
- }
-
- layer{
- name: "fc1"
- type: kInnerProduct
- srclayers:"data"
- innerproduct_conf{
- num_output: 2500
- }
- param{
- name: "w1"
- init {
- type: kUniform
- low:-0.05
- high:0.05
- }
- }
- param{
- name: "b1"
- init {
- type : kUniform
- low: -0.05
- high:0.05
- }
- }
- }
-
- layer{
- name: "tanh1"
- type: kSTanh
- srclayers:"fc1"
- }
- layer{
- name: "fc2"
- type: kInnerProduct
- srclayers:"tanh1"
- innerproduct_conf{
- num_output: 2000
- }
- param{
- name: "w2"
- init {
- type: kUniform
- low:-0.05
- high:0.05
- }
- }
- param{
- name: "b2"
- init {
- type: kUniform
- low: -0.05
- high:0.05
- }
- }
- }
-
- layer{
- name: "tanh2"
- type: kSTanh
- srclayers:"fc2"
- }
- layer{
- name: "fc3"
- type: kInnerProduct
- srclayers:"tanh2"
- innerproduct_conf{
- num_output: 1500
- }
- param{
- name: "w3"
- init{
- type: kUniform
- low:-0.05
- high:0.05
- }
- }
- param{
- name: "b3"
- init {
- type : kUniform
- low: -0.05
- high:0.05
- }
- }
-
- }
-
- layer{
- name: "tanh3"
- type: kSTanh
- srclayers:"fc3"
- }
- layer{
- name: "fc4"
- type: kInnerProduct
- srclayers:"tanh3"
- innerproduct_conf{
- num_output: 1000
- }
- param{
- name: "w4"
- init {
- type : kUniform
- low:-0.05
- high:0.05
- }
- }
- param{
- name: "b4"
- init {
- type : kUniform
- low: -0.05
- high:0.05
- }
- }
-
- }
-
- layer{
- name: "tanh4"
- type: kSTanh
- srclayers:"fc4"
- }
- layer{
- name: "fc5"
- type: kInnerProduct
- srclayers:"tanh4"
- innerproduct_conf{
- num_output: 500
- }
- param{
- name: "w5"
- init {
- type : kUniform
- low:-0.05
- high:0.05
- }
- }
- param{
- name: "b5"
- init {
- type : kUniform
- low: -0.05
- high:0.05
- }
- }
- }
-
- layer{
- name: "tanh5"
- type: kSTanh
- srclayers:"fc5"
- }
- layer{
- name: "fc6"
- type: kInnerProduct
- srclayers:"tanh5"
- innerproduct_conf{
- num_output: 10
- }
- param{
- name: "w6"
- init {
- type : kUniform
- low:-0.05
- high:0.05
- }
- }
- param{
- name: "b6"
- init {
- type : kUniform
- low: -0.05
- high:0.05
- }
- }
- }
- layer{
- name: "loss"
- type:kSoftmaxLoss
- softmaxloss_conf{
- topk:1
- }
- srclayers:"fc6"
- srclayers:"data"
- }
-}
-cluster {
- nworker_groups: 1
- nserver_groups: 1
- workspace: "examples/mnist"
-}
http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/dd1e4afa/examples/mnist/rbm_job.conf
----------------------------------------------------------------------
diff --git a/examples/mnist/rbm_job.conf b/examples/mnist/rbm_job.conf
deleted file mode 100644
index 59a58dd..0000000
--- a/examples/mnist/rbm_job.conf
+++ /dev/null
@@ -1,95 +0,0 @@
-cluster {
- nworker_groups: 1
- nserver_groups: 1
- nservers_per_group: 1
- nworkers_per_group: 1
- workspace: "examples/mnist"
-}
-
-model {
- name: "deep-big-simple-dbm"
- train_steps: 46000
- test_steps:1
- test_frequency:1000
- display_frequency: 100
- alg: kContrastiveDivergence
- pcd_k: 15
- updater{
- base_lr: 0.1
- lr_change: kFixed
- type: kSGD
- }
-
- neuralnet {
- layer {
- name: "data"
- type: kShardData
- sharddata_conf {
- path: "examples/mnist/mnist_train_shard"
- batchsize: 20
- }
- include: kTrain
- }
-
-
- layer {
- name: "data"
- type: kShardData
- sharddata_conf {
- path: "examples/mnist/mnist_test_shard"
- batchsize: 20
- }
- include: kTest
- }
-
-
- layer{
- name:"mnist"
- type: kMnist
- srclayers: "data"
- mnist_conf {
- norm_a: 255
- norm_b: 0
- }
- }
-
- layer{
- name: "RBMVis"
- type: kRBMVis
- srclayers:"mnist"
- srclayers:"RBMHid"
- rbmvis_conf{
- num_output: 500
- }
- param{
- name: "w1"
- init_method: kUniformSqrtFanInOut
- low:-9.79
- high:9.79
- }
- param{
- name: "b1"
- init_method: kConstant
- value: 0.0
- }
- }
-
- layer{
- name: "RBMHid"
- type: kRBMHid
- srclayers:"RBMVis"
- rbmhid_conf{
- hid_dim: 500
- }
- param{
- name: "w2"
- share_from: "w1"
- }
- param{
- name: "b2"
- init_method: kConstant
- value: 0.0
- }
- }
- }
-}