Return-Path: X-Original-To: apmail-singa-commits-archive@minotaur.apache.org Delivered-To: apmail-singa-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3C1FA185DC for ; Sun, 11 Oct 2015 07:24:45 +0000 (UTC) Received: (qmail 6256 invoked by uid 500); 11 Oct 2015 07:24:44 -0000 Delivered-To: apmail-singa-commits-archive@singa.apache.org Received: (qmail 6237 invoked by uid 500); 11 Oct 2015 07:24:44 -0000 Mailing-List: contact commits-help@singa.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@singa.incubator.apache.org Delivered-To: mailing list commits@singa.incubator.apache.org Received: (qmail 6228 invoked by uid 99); 11 Oct 2015 07:24:44 -0000 Received: from Unknown (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 11 Oct 2015 07:24:44 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 29BFBC5548 for ; Sun, 11 Oct 2015 07:24:44 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.791 X-Spam-Level: * X-Spam-Status: No, score=1.791 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, T_RP_MATCHES_RCVD=-0.01, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-us-west.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id 969NhP01oI9n for ; Sun, 11 Oct 2015 07:24:32 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-us-west.apache.org (ASF Mail Server at mx1-us-west.apache.org) with ESMTP id 4C68C2045A for ; Sun, 11 Oct 2015 07:24:32 +0000 (UTC) Received: from svn01-us-west.apache.org (svn.apache.org [10.41.0.6]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id B0467E047E for ; Sun, 11 Oct 2015 07:24:31 +0000 (UTC) Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id 21B0F3A043E for ; Sun, 11 Oct 2015 07:24:31 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1707954 - in /incubator/singa/site/trunk/content/markdown/docs: index.md test.md Date: Sun, 11 Oct 2015 07:24:30 -0000 To: commits@singa.incubator.apache.org From: wangwei@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20151011072431.21B0F3A043E@svn01-us-west.apache.org> Author: wangwei Date: Sun Oct 11 07:24:30 2015 New Revision: 1707954 URL: http://svn.apache.org/viewvc?rev=1707954&view=rev Log: add docs for performance test and feature extraction in test.md Added: incubator/singa/site/trunk/content/markdown/docs/test.md Modified: incubator/singa/site/trunk/content/markdown/docs/index.md Modified: incubator/singa/site/trunk/content/markdown/docs/index.md URL: http://svn.apache.org/viewvc/incubator/singa/site/trunk/content/markdown/docs/index.md?rev=1707954&r1=1707953&r2=1707954&view=diff ============================================================================== --- incubator/singa/site/trunk/content/markdown/docs/index.md (original) +++ incubator/singa/site/trunk/content/markdown/docs/index.md Sun Oct 11 07:24:30 2015 @@ -12,6 +12,7 @@ * [Distributed Training](distributed-training.html) * [Data Preparation](data.html) * [Checkpoint and Resume](checkpoint.html) +* [Performance test and Feature extraction](test.html) * [Examples](examples.html) * Feed-forward models * [CNN](cnn.html) Added: incubator/singa/site/trunk/content/markdown/docs/test.md URL: http://svn.apache.org/viewvc/incubator/singa/site/trunk/content/markdown/docs/test.md?rev=1707954&view=auto ============================================================================== --- incubator/singa/site/trunk/content/markdown/docs/test.md (added) +++ incubator/singa/site/trunk/content/markdown/docs/test.md Sun Oct 11 07:24:30 2015 @@ -0,0 +1,82 @@ +# Performance Test and Feature Extraction + +---- + +Once SINGA finishes the training of a model, it would checkpoint the model parameters +into disk files under the [checkpoint folder](checkpoint.html). Model parameters can also be dumped +into this folder periodically during training if the +[checkpoint configuration[(checkpoint.html) fields are set. With the checkpoint +files, we can load the model parameters to conduct performance test or feature extraction +against new data. + +To load the model parameters from checkpoint files, we need to add the paths of +checkpoint files in the job configuration file + + checkpoint_path: PATH_TO_CHECKPOINT_FILE1 + checkpoint_path: PATH_TO_CHECKPOINT_FILE2 + ... + +The new dataset is configured by specifying the ``test_step`` and the data input +layer, e.g. the following configuration is for a dataset with 100*100 instances. + + test_steps: 100 + net { + layer { + name: "input" + store_conf { + backend: "kvfile" + path: PATH_TO_TEST_KVFILE + batchsize: 100 + } + } + ... + } + +## Performance Test + +This application is to test the performance, e.g., accuracy, of the previously +trained model. Depending on the application, the test data may have ground truth +labels or not. For example, if the model is trained for image classification, +the test images must have ground truth labels to calculate the accuracy; if the +model is an auto-encoder, the performance could be measured by reconstruction error, which +does not require extra labels. For both cases, there would be a layer that calculates +the performance, e.g., the `SoftmaxLossLayer`. + +The job configuration file for the cifar10 example can be used directly for testing after +adding the checkpoint path. The running command is + + + $ ./bin/singa-run.sh -conf examples/cifar10/job.conf -test + +The performance would be output on the screen like, + + + Load from checkpoint file examples/cifar10/checkpoint/step50000-worker0 + accuracy = 0.728000, loss = 0.807645 + +## Feature extraction + +Since deep learning models are good at learning features, feature extraction for +is a major functionality of deep learning models, e.g., we can extract features +from the fully connected layers of [AlexNet](www.cs.toronto.edu/~fritz/absps/imagenet.pdf) as image features for image retrieval. +To extract the features from one layer, we simply add an output layer after that layer. +For instance, to extract the fully connected (with name `ip1`) layer of the cifar10 example model, +we replace the `SoftmaxLossLayer` with a `CSVOutputLayer` which extracts the features into a CSV file, + + layer { + name: "ip1" + } + layer { + name: "output" + type: kCSVOutput + srclayers: "ip1" + store_conf { + backend: "textfile" + path: OUTPUT_FILE_PATH + } + } + +The input layer and test steps, and the running command are the same as in *Performance Test* section. + +If the output layer is connected to a layer that predicts labels of images, +the output layer would then write the prediction results into files.