Skip to content

Commit 691ea56

Browse files
Revert back to using tf.distribution instead of tfp
For reasons not fully understood, using TensorFlow Probability causes Travis CI to use too much memory and a core dump occurs. So until this is understood all use of tfp should be reverted to a combination of tf.distributions and tf.contrib.distributions (for the Poisson). This is really annoying, but at least a temporary fix that doesn't break all functionality and gains. c.f. - pytest-dev/pytest#3527 - travis-ci/travis-ci#9153
1 parent 02b4d30 commit 691ea56

File tree

3 files changed

+22
-11
lines changed

3 files changed

+22
-11
lines changed

.travis.yml

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,13 @@ python:
55
- '2.7'
66
- '3.6'
77
before_install:
8-
- pip install --upgrade pip setuptools
8+
- pip install --upgrade pip setuptools wheel
99
install:
1010
- pip install --ignore-installed -U -q -e .[tensorflow,torch,mxnet,minuit,develop] # Ensure right version of NumPy installed
11+
- pip freeze
1112
script:
1213
- pyflakes pyhf
13-
# pytest takes up too much memory in Travis if run all at once, so split off
14-
# test_notebooks.py into its own pytest run
1514
- pytest --ignore tests/benchmarks/ --ignore tests/test_notebooks.py
16-
- pytest tests/test_notebooks.py
1715
after_success: coveralls
1816

1917
# always test (on both 'push' and 'pr' builds in Travis)
@@ -34,21 +32,31 @@ env:
3432

3533
jobs:
3634
include:
35+
-
36+
python: '2.7'
37+
script:
38+
- pytest tests/test_notebooks.py
39+
-
40+
python: '3.6'
41+
script:
42+
- pytest tests/test_notebooks.py
3743
- stage: benchmark
3844
python: '3.6'
3945
before_install:
40-
- pip install --upgrade pip setuptools
46+
- pip install --upgrade pip setuptools wheel
4147
install:
4248
- pip install --ignore-installed -U -q -e .[tensorflow,torch,mxnet,develop]
49+
- pip freeze
4350
script: pytest --benchmark-sort=mean tests/benchmarks/
4451
- stage: docs
4552
python: '3.6'
4653
before_install:
4754
- sudo apt-get update
4855
- sudo apt-get -qq install pandoc
49-
- pip install --upgrade pip setuptools
56+
- pip install --upgrade pip setuptools wheel
5057
install:
5158
- pip install --ignore-installed -U -q -e .[tensorflow,torch,mxnet,develop]
59+
- pip freeze
5260
script:
5361
- python -m doctest README.md
5462
- cd docs && make html && cd -

pyhf/tensor/tensorflow_backend.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import logging
22
import tensorflow as tf
3-
import tensorflow_probability as tfp
3+
# import tensorflow_probability as tfp
44

55
log = logging.getLogger(__name__)
66

@@ -226,7 +226,8 @@ def poisson(self, n, lam):
226226
"""
227227
n = self.astensor(n)
228228
lam = self.astensor(lam)
229-
return tf.exp(tfp.distributions.Poisson(lam).log_prob(n))
229+
# return tf.exp(tfp.distributions.Poisson(lam).log_prob(n))
230+
return tf.exp(tf.contrib.distributions.Poisson(lam).log_prob(n))
230231

231232
def normal(self, x, mu, sigma):
232233
"""
@@ -256,7 +257,8 @@ def normal(self, x, mu, sigma):
256257
x = self.astensor(x)
257258
mu = self.astensor(mu)
258259
sigma = self.astensor(sigma)
259-
normal = tfp.distributions.Normal(mu, sigma)
260+
# normal = tfp.distributions.Normal(mu, sigma)
261+
normal = tf.distributions.Normal(mu, sigma)
260262
return normal.prob(x)
261263

262264
def normal_cdf(self, x, mu=0, sigma=1):
@@ -286,5 +288,6 @@ def normal_cdf(self, x, mu=0, sigma=1):
286288
x = self.astensor(x)
287289
mu = self.astensor(mu)
288290
sigma = self.astensor(sigma)
289-
normal = tfp.distributions.Normal(mu, sigma)
291+
# normal = tfp.distributions.Normal(mu, sigma)
292+
normal = tf.distributions.Normal(mu, sigma)
290293
return normal.cdf(x)

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
],
3535
'tensorflow':[
3636
'tensorflow>=1.10.0',
37+
# 'tensorflow-probability>=0.3.0', # Causing troulbe with Travis CI, but *should* be used
3738
'numpy<=1.14.5,>=1.14.0', # Lower of 1.14.0 instead of 1.13.3 to ensure doctest pass
38-
'tensorflow-probability>=0.3.0',
3939
'setuptools<=39.1.0',
4040
],
4141
'develop': [

0 commit comments

Comments
 (0)