fix minor erros from installation.md and examples/cifar10/predict.py
diff --git a/doc/en/docs/installation.md b/doc/en/docs/installation.md
index a8b0530..6dda3f4 100755
--- a/doc/en/docs/installation.md
+++ b/doc/en/docs/installation.md
@@ -138,27 +138,15 @@
## Build SINGA from source
-### From the downloaded `tar.gz` file:
-
-Extract the downloaded. If using CUDA, CNMeM needs to be fetched:
-
- $ cd $SINGA_ROOT/lib/cnmem/
- $ git clone https://github.com/NVIDIA/cnmem
-
-### From Git:
-
-Please clone the newest code from [Github](https://github.com/apache/incubator-singa) and execute the following commands,
+The source files could be downloaded either as a [tar.gz file](https://dist.apache.org/repos/dist/dev/incubator/singa/1.0.0/apache-singa-incubating-1.0.0-RC2.tar.gz), or as a git repo
$ git clone https://github.com/apache/incubator-singa.git
$ cd incubator-singa/
-If you use CUDA, then [CNMeM](https://github.com/NVIDIA/cnmem) is necessary,
-which could be downloaded as
-
+ # If you use CUDA, then CNMeM is necessary
$ git submodule init
$ git submodule update
-
### Linux & MacOS
GCC (>=4.8.1) is required to compile SINGA on Linux.
@@ -178,7 +166,11 @@
$ export CMAKE_LIBRARY_PATH=<path to cudnn>/lib64:$CMAKE_LIBRARY_PATH
You can use `ccmake ..` to configure the compilation options including using
-generating python binding and changing the installation folder.
+generating python binding and changing the installation folder. Alternatively,
+the options could be switched on by
+
+ $ cmake -DUSE_CUDA=ON -DUSE_PYTHON=ON ..
+
If the dependent libraries are not in the system default paths, you need to export
the following environment variables
diff --git a/examples/char-rnn/sample.py b/examples/char-rnn/sample.py
index bbfb28f..9b6e757 100644
--- a/examples/char-rnn/sample.py
+++ b/examples/char-rnn/sample.py
@@ -93,7 +93,7 @@
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='sample chars from char-rnn')
- parser.add_argument('model', type=int, help='the model checkpoint file')
+ parser.add_argument('model', help='the model checkpoint file')
parser.add_argument('n', type=int, help='num of characters to sample')
parser.add_argument('--seed', help='seed text string which warms up the '
' rnn states for sampling', default='')
diff --git a/examples/cifar10/README.md b/examples/cifar10/README.md
index de122f7..0cf069f 100644
--- a/examples/cifar10/README.md
+++ b/examples/cifar10/README.md
@@ -66,5 +66,9 @@
The net is created by loading the previously trained model; Images consist of
a numpy array of images (one row per image); dev is the training device, e.g.,
-a CudaGPU device or the host CppCPU device; topk labels of each image would be
-returned.
+a CudaGPU device or the host CppCPU device; It returns the topk labels for each instance.
+
+The predict.py file's main function provides an example of using the pre-trained alexnet model to do prediction for new images.
+The 'model.bin' file generated by the training program should be placed at the cifar10 folder to run
+
+ python predict.py
diff --git a/examples/cifar10/predict.py b/examples/cifar10/predict.py
index 307a610..f2150f4 100644
--- a/examples/cifar10/predict.py
+++ b/examples/cifar10/predict.py
@@ -14,6 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# =============================================================================
+'''Predicting the labels for new images using the pre-trained alexnet model'''
import cPickle as pickle
import numpy as np
@@ -21,7 +22,7 @@
from singa import device
from singa import tensor
-import net as ffnet
+import alexnet
def predict(net, images, dev, topk=5):
@@ -38,10 +39,10 @@
x.to_device(dev)
y = net.predict(x)
y.to_host()
- y = tensor.to_numpy(y)
- prob = np.average(y, 0)
+ prob = tensor.to_numpy(y)
+ # prob = np.average(prob, 0)
labels = np.flipud(np.argsort(prob)) # sort prob in descending order
- return labels[0:topk], prob[labels[0:topk]]
+ return labels[:, 0:topk]
def load_dataset(filepath):
@@ -75,16 +76,16 @@
def compute_image_mean(train_dir):
- images = np.load(train_dir)
+ images, _ = load_train_data(train_dir)
return np.average(images, 0)
if __name__ == '__main__':
- model = ffnet.create_alexnet()
- model.load('model.bin')
- cuda = device.create_cuda_gpu()
- model.to_device(cuda)
+ model = alexnet.create_net(True)
+ model.load('model.bin') # the checkpoint from train.py
+ dev = device.get_default_device()
+ model.to_device(dev)
mean = compute_image_mean('cifar-10-batches-py')
test_images, _ = load_test_data('cifar-10-batches-py')
- # minus mean is for alexnet; vgg uses a different pre-processing strategy
- print predict(model, test_images - mean, cuda)
+ # predict for two images
+ print predict(model, test_images[0:2] - mean, dev)