[caffe-contrib] 05/11: tests: import autopkgtest files from cpu version
Zhou Mo
cdluminate-guest at moszumanska.debian.org
Mon Nov 28 02:50:11 UTC 2016
This is an automated email from the git hooks/post-receive script.
cdluminate-guest pushed a commit to branch master
in repository caffe-contrib.
commit c8cf728422ac0afb1f1422c0f2a90a3147521572
Author: Zhou Mo <cdluminate at gmail.com>
Date: Mon Nov 28 02:40:59 2016 +0000
tests: import autopkgtest files from cpu version
---
debian/changelog | 2 ++
debian/tests/.python-caffe-test.py | 43 ++++++++++++++++++++++++++++++++
debian/tests/control | 8 ++++--
debian/tests/simply.run | 7 ++++++
debian/tests/test.forward.backward.lenet | 9 +++++++
debian/tests/test.python3.import | 7 ++++++
debian/tests/test.python3.simple.forward | 6 +++++
7 files changed, 80 insertions(+), 2 deletions(-)
diff --git a/debian/changelog b/debian/changelog
index 8a4bcd7..9133553 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -5,6 +5,8 @@ caffe-contrib (1.0.0~rc3+20160930-ga7f950b-2) UNRELEASED; urgency=medium
* Remove NVCC flag "-D_FORCE_INLINES" (CUDA 7.5 workaround).
* Refresh symbols control file for amd64.
* Add python3-protobuf to B-D.
+ * Import files from src:caffe_1.0.0~rc3+20160930-ga7f950b-3 :
+ + autopkgtest files
-- Zhou Mo <cdluminate at gmail.com> Sat, 26 Nov 2016 07:18:43 +0000
diff --git a/debian/tests/.python-caffe-test.py b/debian/tests/.python-caffe-test.py
new file mode 100644
index 0000000..df2c883
--- /dev/null
+++ b/debian/tests/.python-caffe-test.py
@@ -0,0 +1,43 @@
+#!/usr/bin/env python
+'''
+Caffe Python Module Testsuite for Debian Package
+Copyright (C) 2016 Zhou Mo
+
+Reference:
+http://nbviewer.jupyter.org/github/BVLC/caffe/blob/master/examples/01-learning-lenet.ipynb
+http://nbviewer.jupyter.org/github/BVLC/caffe/blob/master/examples/net_surgery.ipynb
+'''
+
+import numpy
+import caffe
+
+def test_lenet_benchmark():
+ # load lenet deploy network
+ model_definition = "examples/mnist/lenet.prototxt"
+ caffe.set_mode_cpu()
+ model = caffe.Net(model_definition, caffe.TEST)
+ # populate random data and copy it to network
+ batch = numpy.random.randn(64, 1, 28, 28)
+ model.blobs['data'].reshape(64, 1, 28, 28)
+ model.blobs['data'].data[...] = batch
+ # randomly fill parameter into network
+ model.params['conv1'][0].data.shape # access test, this should be (20, 1, 5, 5)
+ model.params['conv1'][0].flat = numpy.random.randn(20, 1, 5, 5).flat
+ model.params['conv1'][1].flat = numpy.random.randn(20,).flat
+ model.params['conv2'][0].flat = numpy.random.randn(50, 20, 5, 5).flat
+ model.params['conv2'][1].flat = numpy.random.randn(50,).flat
+ model.params['ip1'][0].flat = numpy.random.randn(500, 800).flat
+ model.params['ip1'][1].flat = numpy.random.randn(500,).flat
+ model.params['ip2'][0].flat = numpy.random.randn(10, 500).flat
+ model.params['ip2'][1].flat = numpy.random.randn(10,).flat
+ # forward this network, here we don't care neither the network parameters nor the result.
+ output = model.forward()
+ output_prob = output['prob'][0] # prob vector for the first image in batch
+ prediction = output_prob.argmax()
+ print ('This mindless benchmark ends up with an arbitary output {}'.format(prediction))
+
+def main():
+ test_lenet_benchmark()
+
+if __name__ == "__main__":
+ main()
diff --git a/debian/tests/control b/debian/tests/control
index be21b5a..bf30ddc 100644
--- a/debian/tests/control
+++ b/debian/tests/control
@@ -1,3 +1,7 @@
-Tests: simple
+Tests: simply.run
-Tests: python3caffetestsuite
+Tests: test.forward.backward.lenet
+
+Tests: test.python3.import
+
+Tests: test.python3.simple.forward
diff --git a/debian/tests/simply.run b/debian/tests/simply.run
new file mode 100755
index 0000000..96333c4
--- /dev/null
+++ b/debian/tests/simply.run
@@ -0,0 +1,7 @@
+#!/bin/sh
+set -e
+
+# simply run caffe to see if it explodes.
+caffe
+
+exit 0
diff --git a/debian/tests/test.forward.backward.lenet b/debian/tests/test.forward.backward.lenet
new file mode 100755
index 0000000..b5824f8
--- /dev/null
+++ b/debian/tests/test.forward.backward.lenet
@@ -0,0 +1,9 @@
+#!/bin/sh
+set -e
+
+# using the deploy version of lenet for a benchmark test, which requires
+# no MNIST dataset.
+model=examples/mnist/lenet.prototxt
+
+# launch a caffe benchmark on the above network
+caffe time -model $model -iterations 50
diff --git a/debian/tests/test.python3.import b/debian/tests/test.python3.import
new file mode 100755
index 0000000..fa5371b
--- /dev/null
+++ b/debian/tests/test.python3.import
@@ -0,0 +1,7 @@
+#!/bin/sh
+set -e
+
+# we want to know if it imports correctly
+python3 -c 'import caffe'
+
+exit 0
diff --git a/debian/tests/test.python3.simple.forward b/debian/tests/test.python3.simple.forward
new file mode 100755
index 0000000..2272cec
--- /dev/null
+++ b/debian/tests/test.python3.simple.forward
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+# perform a simple functional test
+python3 debian/tests/.python-caffe-test.py
+
+exit 0
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/caffe-contrib.git
More information about the debian-science-commits
mailing list