Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
sudo: required
dist: trusty
language: python
matrix:
include:
- python: 2.7
- python: 3.4
python:
- 2.7
- 3.4
- 3.6
env:
- TF=1.3.0rc0
- TF=1.5.0
- TF=1.7.0
notifications:
email: false
before_install:
Expand Down Expand Up @@ -37,7 +41,7 @@ install:
- pip install keras
- pip install matplotlib seaborn scipy
- pip install networkx==1.9.1 observations sklearn
- pip install tensorflow==1.5.0
- pip install tensorflow==$TF
- pip install pystan
- pip install nbformat nbconvert jupyter_client jupyter
- python setup.py install
Expand Down
6 changes: 5 additions & 1 deletion edward/util/random_variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@
from edward.models import PointMass
from edward.util.graphs import random_variables
from tensorflow.core.framework import attr_value_pb2
from tensorflow.python.framework.ops import set_shapes_for_outputs
from tensorflow.python.util import compat
try:
from tensorflow.python.framework.ops import set_shapes_for_outputs
except ImportError:
from tensorflow.python.framework.ops import \
set_shape_and_handle_data_for_outputs as set_shapes_for_outputs

tfb = tf.contrib.distributions.bijectors

Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
install_requires=['numpy>=1.7',
'six>=1.10.0'],
extras_require={
'tensorflow': ['tensorflow>=1.2.0rc0'],
'tensorflow with gpu': ['tensorflow-gpu>=1.2.0rc0'],
'tensorflow': ['tensorflow >=1.3.0rc0, <=1.7.0'],
'tensorflow with gpu': ['tensorflow-gpu >=1.3.0rc0, <=1.7.0'],
'neural networks': ['keras>=2.0.0', 'prettytensor>=0.7.4'],
'datasets': ['observations>=0.1.2'],
'notebooks': ['jupyter>=1.0.0'],
Expand Down
14 changes: 9 additions & 5 deletions tests/criticisms/metrics_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,23 +46,27 @@ class test_metrics_class(tf.test.TestCase):

def _check_averaging(self, metric, y_true, y_pred):
n_classes = tf.squeeze(tf.shape(y_true)[-1]).eval()
class_scores = [metric(y_true[i], y_pred[i]) for i in range(n_classes)]
class_scores = [metric(y_true[:, i], y_pred[:, i])
for i in range(n_classes)]

# No averaging
no_average = metric(y_true, y_pred, average=None)
expected_no_average = tf.stack(class_scores)
self.assertAllEqual(no_average.eval(), expected_no_average.eval())
self.assertAllCloseAccordingToType(
no_average.eval(), expected_no_average.eval())

# Macro-averaging
macro_average = metric(y_true, y_pred, average='macro')
expected_macro_average = tf.reduce_mean(tf.stack(class_scores))
self.assertAllEqual(macro_average.eval(), expected_macro_average.eval())
self.assertAllCloseAccordingToType(
macro_average.eval(), expected_macro_average.eval())

# Micro-averaging
micro_average = metric(y_true, y_pred, average='micro')
expected_micro_average = metric(tf.reshape(y_true, [1, -1]),
tf.reshape(y_pred, [1, -1]))
self.assertAllEqual(micro_average.eval(), expected_micro_average.eval())
self.assertAllCloseAccordingToType(
micro_average.eval(), expected_micro_average.eval())

def test_classification_metrics(self):
with self.test_session():
Expand Down Expand Up @@ -106,7 +110,7 @@ def test_specialized_input_output_metrics(self):
def test_metrics_with_binary_averaging(self):
with self.test_session():
y_true = tf.constant([[1.0, 2.0, 3.0], [2.0, 3.0, 4.0], [3.0, 4.0, 5.0]])
y_pred = tf.constant([[2.0, 4.0, 6.0], [4.0, 6.0, 8.0], [6.0, 8.0, 10.0]])
y_pred = tf.constant([[3.0, 4.0, 3.0], [6.0, 6.0, 4.0], [9.0, 8.0, 5.0]])
for metric in all_metrics_with_binary_averaging:
self._check_averaging(metric, y_true, y_pred)

Expand Down