Skip to content

Commit f75d5e3

Browse files
authored
Merge branch 'master' into github_templates
2 parents 77602a0 + 6f539ad commit f75d5e3

28 files changed

+1984
-1338
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ dist
1010
docs/_build
1111
tensorlayer.egg-info
1212
tensorlayer/__pacache__
13-
venv/
13+
venv/
14+
.pytest_cache/

.travis.yml

Lines changed: 41 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,56 @@
11
# https://docs.travis-ci.com/user/languages/python/
22
language: python
3+
34
python:
45
- "2.7"
56
- "3.5"
67
- "3.6"
78

9+
#env:
10+
# global:
11+
#
12+
# ### == PYPI_PASSWORD === ###
13+
# - secure: "##############################################################"
14+
#
15+
# ### === GITHUB_PERSONAL_TOKEN === ###
16+
# - secure: "##############################################################"
17+
18+
819
install:
920
- pip install tensorflow
1021
- pip install -r requirements.txt
11-
- pip install -r tests/requirements.txt
12-
- pip install .
22+
- pip install .[test]
23+
1324

1425
script:
1526
# units test
1627
# https://docs.pytest.org/en/latest/
17-
# TODO: make it work
18-
# - pytest
28+
- pytest
29+
30+
31+
before_deploy:
32+
- python setup.py sdist
33+
- python setup.py bdist_wheel
34+
- python setup.py bdist_wheel --universal
35+
- python setup.py egg_info
36+
37+
38+
#deploy:
39+
#- provider: pypi
40+
# user: zsdh123
41+
# password: "$PYPI_PASSWORD"
42+
# skip_cleanup: true
43+
# on:
44+
# tags: true
45+
# python: '3.6'
1946

20-
# smoke tests
21-
# - make test # TODO: make it use python3 by default
22-
- python tests/test_yapf_format.py
23-
- python tests/test_pydocstyle.py
24-
- python tests/test_mnist_simple.py
25-
- python tests/test_reuse_mlp.py
26-
- python tests/test_layers_basic.py
27-
- python tests/test_layers_convolution.py
28-
- python tests/test_layers_core.py
29-
- python tests/test_layers_extend.py
30-
- python tests/test_layers_flow_control.py
31-
- python tests/test_layers_importer.py
32-
- python tests/test_layers_merge.py
33-
- python tests/test_layers_normalization.py
34-
- python tests/test_layers_padding.py
35-
- python tests/test_layers_pooling.py
36-
- python tests/test_layers_recurrent.py
37-
- python tests/test_layers_shape.py
38-
- python tests/test_layers_spatial_transformer.py
39-
- python tests/test_layers_special_activation.py
40-
- python tests/test_layers_stack.py
41-
- python tests/test_layers_super_resolution.py
42-
- python tests/test_layers_time_distributed.py
43-
- python tests/test_models.py
47+
#- provider: releases
48+
# file:
49+
# - dist/*
50+
# - tensorlayer.egg-info/PKG-INFO
51+
# file_glob: true
52+
# skip_cleanup: true
53+
# api_key: "$GITHUB_PERSONAL_TOKEN"
54+
# on:
55+
# tags: true
56+
# python: '3.6'

pytest.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[pytest]
2+
testpaths = tests/

setup.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,6 @@ def req_file(filename):
133133
extras_require={
134134
'test': req_file("tests/requirements.txt")
135135
},
136-
137-
zip_safe=True,
138-
include_package_data=True,
139136
scripts=[
140137
'tl',
141138
],

tests/requirements.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1-
yapf==0.20.2
2-
pydocstyle==2.1.1
31
keras==2.1.5
2+
pydocstyle==2.1.1
3+
pytest==3.4.1
4+
pytest-cache==1.0
5+
pytest-cov==2.5.1
6+
pytest-xdist==1.22.2
7+
yapf==0.20.2

tests/test_layers_basic.py

Lines changed: 44 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,55 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
import unittest
4+
15
import tensorflow as tf
26
import tensorlayer as tl
37

4-
x = tf.placeholder(tf.float32, [None, 100])
5-
n = tl.layers.InputLayer(x, name='in')
6-
n = tl.layers.DenseLayer(n, n_units=80, name='d1')
7-
n = tl.layers.DenseLayer(n, n_units=80, name='d2')
8-
print(n)
9-
n.print_layers()
10-
n.print_params(False)
11-
print(n.count_params())
128

13-
if n.count_params() != 14560:
14-
raise Exception("params do not match")
9+
class Layer_Basic_Test(unittest.TestCase):
10+
@classmethod
11+
def setUpClass(cls):
12+
13+
x = tf.placeholder(tf.float32, [None, 100])
14+
n = tl.layers.InputLayer(x, name='in')
15+
n = tl.layers.DenseLayer(n, n_units=80, name='d1')
16+
n = tl.layers.DenseLayer(n, n_units=80, name='d2')
17+
18+
n.print_layers()
19+
n.print_params(False)
20+
21+
n2 = n[:, :30]
22+
n2.print_layers()
23+
24+
cls.n_params = n.count_params()
25+
cls.shape_n = n.outputs.get_shape().as_list()
26+
cls.shape_n2 = n2.outputs.get_shape().as_list()
27+
cls.all_layers = n.all_layers
28+
cls.all_params = n.all_params
29+
30+
@classmethod
31+
def tearDownClass(cls):
32+
tf.reset_default_graph()
33+
34+
def test_n_params(self):
35+
self.assertEqual(self.n_params, 14560)
36+
37+
def test_shape_n(self):
38+
self.assertEqual(self.shape_n[-1], 80)
1539

16-
shape = n.outputs.get_shape().as_list()
17-
if shape[-1] != 80:
18-
raise Exception("shape do not match")
40+
def test_all_layers(self):
41+
self.assertEqual(len(self.all_layers), 2)
1942

20-
if len(n.all_layers) != 2:
21-
raise Exception("layers do not match")
43+
def test_all_params(self):
44+
self.assertEqual(len(self.all_params), 4)
2245

23-
if len(n.all_params) != 4:
24-
raise Exception("params do not match")
46+
def test_shape_n2(self):
47+
self.assertEqual(self.shape_n2[-1], 30)
2548

26-
for l in n:
27-
print(l)
2849

29-
n2 = n[:, :30]
30-
print(n2)
31-
n2.print_layers()
50+
if __name__ == '__main__':
3251

33-
shape = n2.outputs.get_shape().as_list()
34-
if shape[-1] != 30:
35-
raise Exception("shape do not match")
52+
# tf.logging.set_verbosity(tf.logging.INFO)
53+
tf.logging.set_verbosity(tf.logging.DEBUG)
3654

37-
for l in n2:
38-
print(l)
55+
unittest.main()

0 commit comments

Comments
 (0)