Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
LBN
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
2
Issues
2
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
1
Merge Requests
1
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Test Cases
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
3pia
LBN
Commits
edd977bb
Commit
edd977bb
authored
Apr 13, 2019
by
Marcel Rieger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make tests compatible between tf 1 and 2.
parent
c69e0f5b
Pipeline
#118292
passed with stages
in 39 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
7 deletions
+34
-7
.gitlab-ci.yml
.gitlab-ci.yml
+18
-2
test.py
test.py
+16
-5
No files found.
.gitlab-ci.yml
View file @
edd977bb
...
...
@@ -12,7 +12,23 @@ lint:
-
pip install flake8 --user
-
flake8 lbn.py test.py setup.py
unittests_py2
:
unittest_tf1_py2
:
stage
:
test
tags
:
-
docker
image
:
tensorflow/tensorflow:1.13.1
script
:
-
python -m unittest test
unittests_tf1_py3
:
stage
:
test
tags
:
-
docker
image
:
tensorflow/tensorflow:1.13.1-py3
script
:
-
python -m unittest test
unittest_tf2_py2
:
stage
:
test
tags
:
-
docker
...
...
@@ -20,7 +36,7 @@ unittests_py2:
script
:
-
python -m unittest test
unittests_py3
:
unittests_
tf2_
py3
:
stage
:
test
tags
:
-
docker
...
...
test.py
View file @
edd977bb
...
...
@@ -8,6 +8,7 @@ LBN unit tests.
__all__
=
[
"TestCase"
]
import
sys
import
unittest
import
numpy
as
np
...
...
@@ -16,6 +17,13 @@ import tensorflow as tf
from
lbn
import
LBN
,
LBNLayer
,
FeatureFactory
PY3
=
sys
.
version
.
startswith
(
"3."
)
TF2
=
tf
.
__version__
.
startswith
(
"2."
)
if
not
TF2
:
tf
.
enable_eager_execution
()
class
TestCase
(
unittest
.
TestCase
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
...
...
@@ -23,7 +31,10 @@ class TestCase(unittest.TestCase):
# fixate random seeds
np
.
random
.
seed
(
123
)
tf
.
random
.
set_seed
(
123
)
if
TF2
:
tf
.
random
.
set_seed
(
123
)
else
:
tf
.
random
.
set_random_seed
(
123
)
# create some four-vectors with fixed seed and batch size 2
self
.
vectors
=
create_four_vectors
((
2
,
10
))
...
...
@@ -337,10 +348,10 @@ class TestCase(unittest.TestCase):
model
=
Model
()
output
=
model
(
self
.
vectors_t
,
features
=
self
.
feature_set
).
numpy
()
self
.
assertAlmostEqual
(
output
[
0
,
0
],
0.548664
,
5
)
self
.
assertAlmostEqual
(
output
[
0
,
1
],
0.451337
,
5
)
self
.
assertAlmostEqual
(
output
[
1
,
0
],
0.394629
,
5
)
self
.
assertAlmostEqual
(
output
[
1
,
1
],
0.605371
,
5
)
self
.
assertAlmostEqual
(
output
[
0
,
0
],
0.548664
if
PY3
else
0.795995
,
5
)
self
.
assertAlmostEqual
(
output
[
0
,
1
],
0.451337
if
PY3
else
0.204005
,
5
)
self
.
assertAlmostEqual
(
output
[
1
,
0
],
0.394629
if
PY3
else
0.177576
,
5
)
self
.
assertAlmostEqual
(
output
[
1
,
1
],
0.605371
if
PY3
else
0.822424
,
5
)
def
create_four_vectors
(
n
,
p_low
=-
100.
,
p_high
=
100.
,
m_low
=
0.1
,
m_high
=
50.
,
seed
=
None
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment