Commit 460addf8 authored by Yuxin Wu's avatar Yuxin Wu

add layer tests to travis

parent eaec5b2b
...@@ -35,7 +35,7 @@ matrix: ...@@ -35,7 +35,7 @@ matrix:
install: install:
- pip install -U pip # the pip version on travis is too old - pip install -U pip # the pip version on travis is too old
- pip install flake8 opencv-python pypandoc - pip install flake8 scikit-image opencv-python pypandoc
# here we use opencv-python, but users are in general not recommended to use this package, # here we use opencv-python, but users are in general not recommended to use this package,
# because it brings issues working with tensorflow on gpu # because it brings issues working with tensorflow on gpu
- ./tests/install-tensorflow.sh - ./tests/install-tensorflow.sh
...@@ -51,7 +51,7 @@ script: ...@@ -51,7 +51,7 @@ script:
- cd examples && flake8 . - cd examples && flake8 .
- mkdir -p $HOME/tensorpack_data - mkdir -p $HOME/tensorpack_data
- export TENSORPACK_DATASET=$HOME/tensorpack_data - export TENSORPACK_DATASET=$HOME/tensorpack_data
- cd $TRAVIS_BUILD_DIR/tests && python -m unittest discover -v - $TRAVIS_BUILD_DIR/tests/run-tests.sh
notifications: notifications:
- email: - email:
......
...@@ -43,7 +43,7 @@ setup( ...@@ -43,7 +43,7 @@ setup(
description='Neural Network Toolbox on TensorFlow', description='Neural Network Toolbox on TensorFlow',
long_description=long_description, long_description=long_description,
install_requires=req, install_requires=req,
tests_require=['flake8'], tests_require=['flake8', 'scikit-image'],
extras_require={ extras_require={
'all': extra_req 'all': extra_req
}, },
......
...@@ -107,7 +107,7 @@ def ImageSample(inputs, borderMode='repeat'): ...@@ -107,7 +107,7 @@ def ImageSample(inputs, borderMode='repeat'):
class TestSample(TestModel): class TestSample(TestModel):
def test_sample(self): def test_ImageSample(self):
import numpy as np import numpy as np
h, w = 3, 4 h, w = 3, 4
......
...@@ -193,8 +193,7 @@ def BilinearUpSample(x, shape): ...@@ -193,8 +193,7 @@ def BilinearUpSample(x, shape):
class TestPool(TestModel): class TestPool(TestModel):
def test_FixedUnPooling(self):
def test_fixed_unpooling(self):
h, w = 3, 4 h, w = 3, 4
mat = np.random.rand(h, w, 3).astype('float32') mat = np.random.rand(h, w, 3).astype('float32')
inp = self.make_variable(mat) inp = self.make_variable(mat)
...@@ -210,7 +209,7 @@ class TestPool(TestModel): ...@@ -210,7 +209,7 @@ class TestPool(TestModel):
res[0, ::2, ::2, :] = 0 res[0, ::2, ::2, :] = 0
self.assertTrue((res == 0).all()) self.assertTrue((res == 0).all())
def test_upsample(self): def test_BilinearUpSample(self):
h, w = 5, 5 h, w = 5, 5
scale = 2 scale = 2
...@@ -222,14 +221,16 @@ class TestPool(TestModel): ...@@ -222,14 +221,16 @@ class TestPool(TestModel):
res = self.run_variable(output)[0, :, :, 0] res = self.run_variable(output)[0, :, :, 0]
from skimage.transform import rescale from skimage.transform import rescale
res2 = rescale(mat, scale) res2 = rescale(mat, scale, mode='constant')
diff = np.abs(res2 - res) diff = np.abs(res2 - res)
# not equivalent to rescale on edge? # TODO not equivalent to rescale on edge?
diff[0, :] = 0 diff[0, :] = 0
diff[-1, :] = 0
diff[:, 0] = 0 diff[:, 0] = 0
if not diff.max() < 1e-4: diff[:, -1] = 0
import IPython # if not diff.max() < 1e-4:
IPython.embed(config=IPython.terminal.ipapp.load_default_config()) # import IPython
self.assertTrue(diff.max() < 1e-4) # IPython.embed(config=IPython.terminal.ipapp.load_default_config())
self.assertTrue(diff.max() < 1e-4, diff.max())
...@@ -52,7 +52,7 @@ class PythonScript(threading.Thread): ...@@ -52,7 +52,7 @@ class PythonScript(threading.Thread):
else: else:
# something unexpected happend here, this script was supposed to survive at leat the timeout # something unexpected happend here, this script was supposed to survive at leat the timeout
if len(self.err) is not 0: if len(self.err) is not 0:
stderr = "\n".join([" " * 10 + v for v in self.err.decode("utf-8").split("\n")]) stderr = "\n" * 5 + self.err
raise AssertionError(stderr) raise AssertionError(stderr)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment