Skip to content

Commit

Permalink
Merge commit for internal changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mrry committed May 18, 2016
2 parents 449d122 + 49ec6ff commit 5ec60d9
Show file tree
Hide file tree
Showing 104 changed files with 5,536 additions and 645 deletions.
8 changes: 4 additions & 4 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ new_git_repository(
name = "iron_behaviors",
build_file = "bower.BUILD",
remote = "https://github.com/polymerelements/iron-behaviors.git",
tag = "v1.0.13",
tag = "v1.0.16",
)

new_git_repository(
Expand Down Expand Up @@ -117,7 +117,7 @@ new_git_repository(
name = "iron_fit_behavior",
build_file = "bower.BUILD",
remote = "https://github.com/polymerelements/iron-fit-behavior.git",
tag = "v1.2.0",
tag = "v1.2.1",
)

new_git_repository(
Expand Down Expand Up @@ -173,7 +173,7 @@ new_git_repository(
name = "iron_menu_behavior",
build_file = "bower.BUILD",
remote = "https://github.com/polymerelements/iron-menu-behavior.git",
tag = "v1.1.6",
tag = "v1.1.7",
)

new_git_repository(
Expand All @@ -187,7 +187,7 @@ new_git_repository(
name = "iron_overlay_behavior",
build_file = "bower.BUILD",
remote = "https://github.com/polymerelements/iron-overlay-behavior.git",
tag = "v1.7.3",
tag = "v1.7.6",
)

new_git_repository(
Expand Down
2 changes: 2 additions & 0 deletions tensorflow/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,15 @@ filegroup(
"//tensorflow/contrib/ffmpeg/kernels:all_files",
"//tensorflow/contrib/framework:all_files",
"//tensorflow/contrib/layers:all_files",
"//tensorflow/contrib/layers/kernels:all_files",
"//tensorflow/contrib/learn:all_files",
"//tensorflow/contrib/linear_optimizer:all_files",
"//tensorflow/contrib/linear_optimizer/kernels:all_files",
"//tensorflow/contrib/lookup:all_files",
"//tensorflow/contrib/losses:all_files",
"//tensorflow/contrib/metrics:all_files",
"//tensorflow/contrib/metrics/kernels:all_files",
"//tensorflow/contrib/opt:all_files",
"//tensorflow/contrib/quantization:all_files",
"//tensorflow/contrib/quantization/kernels:all_files",
"//tensorflow/contrib/quantization/tools:all_files",
Expand Down
1 change: 1 addition & 0 deletions tensorflow/contrib/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ py_library(
"//tensorflow/contrib/lookup:lookup_py",
"//tensorflow/contrib/losses:losses_py",
"//tensorflow/contrib/metrics:metrics_py",
"//tensorflow/contrib/opt:opt_py",
"//tensorflow/contrib/quantization:quantization_py",
"//tensorflow/contrib/rnn:rnn_py",
"//tensorflow/contrib/skflow",
Expand Down
1 change: 1 addition & 0 deletions tensorflow/contrib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from tensorflow.contrib import lookup
from tensorflow.contrib import losses
from tensorflow.contrib import metrics
from tensorflow.contrib import opt
from tensorflow.contrib import quantization
from tensorflow.contrib import rnn
from tensorflow.contrib import skflow
Expand Down
28 changes: 27 additions & 1 deletion tensorflow/contrib/distributions/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,33 @@ cuda_py_tests(
],
)

cuda_py_tests(
name = "gamma_test",
srcs = ["python/kernel_tests/gamma_test.py"],
additional_deps = [
"//tensorflow/python:framework_test_lib",
"//tensorflow/python:platform_test",
],
)

cuda_py_tests(
name = "chi2_test",
srcs = ["python/kernel_tests/chi2_test.py"],
additional_deps = [
"//tensorflow/python:framework_test_lib",
"//tensorflow/python:platform_test",
],
)

cuda_py_tests(
name = "exponential_test",
srcs = ["python/kernel_tests/exponential_test.py"],
additional_deps = [
"//tensorflow/python:framework_test_lib",
"//tensorflow/python:platform_test",
],
)

cuda_py_tests(
name = "gaussian_test",
size = "small",
Expand Down Expand Up @@ -65,7 +92,6 @@ cuda_py_tests(
srcs = ["python/kernel_tests/gaussian_conjugate_posteriors_test.py"],
additional_deps = [
":distributions_py",
"//tensorflow/python:framework_test_lib",
"//tensorflow/python:platform_test",
],
)
Expand Down
7 changes: 7 additions & 0 deletions tensorflow/contrib/distributions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
### Univariate (scalar) distributions
@@Chi2
@@Exponential
@@Gamma
@@Gaussian
@@Uniform
Expand All @@ -50,8 +53,12 @@
from __future__ import print_function

# pylint: disable=unused-import,wildcard-import,line-too-long

from tensorflow.contrib.distributions.python.ops.chi2 import *
from tensorflow.contrib.distributions.python.ops.dirichlet_multinomial import *
from tensorflow.contrib.distributions.python.ops.distribution import *
from tensorflow.contrib.distributions.python.ops.exponential import *
from tensorflow.contrib.distributions.python.ops.gamma import *
from tensorflow.contrib.distributions.python.ops.gaussian import *
from tensorflow.contrib.distributions.python.ops.gaussian_conjugate_posteriors import *
from tensorflow.contrib.distributions.python.ops.mvn import *
Expand Down
85 changes: 85 additions & 0 deletions tensorflow/contrib/distributions/python/kernel_tests/chi2_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# Copyright 2016 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
"""Tests for initializers."""

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import numpy as np
from scipy import stats
import tensorflow as tf


class Chi2Test(tf.test.TestCase):

def testChi2LogPDF(self):
with tf.Session():
batch_size = 6
df = tf.constant([2.0] * batch_size, dtype=np.float64)
df_v = 2.0
x = np.array([2.5, 2.5, 4.0, 0.1, 1.0, 2.0], dtype=np.float64)
chi2 = tf.contrib.distributions.Chi2(df=df)
expected_log_pdf = stats.chi2.logpdf(x, df_v)

log_pdf = chi2.log_pdf(x)
self.assertEqual(log_pdf.get_shape(), (6,))
self.assertAllClose(log_pdf.eval(), expected_log_pdf)

pdf = chi2.pdf(x)
self.assertEqual(pdf.get_shape(), (6,))
self.assertAllClose(pdf.eval(), np.exp(expected_log_pdf))

def testChi2CDF(self):
with tf.Session():
batch_size = 6
df = tf.constant([2.0] * batch_size, dtype=np.float64)
df_v = 2.0
x = np.array([2.5, 2.5, 4.0, 0.1, 1.0, 2.0], dtype=np.float64)

chi2 = tf.contrib.distributions.Chi2(df=df)
expected_cdf = stats.chi2.cdf(x, df_v)

cdf = chi2.cdf(x)
self.assertEqual(cdf.get_shape(), (6,))
self.assertAllClose(cdf.eval(), expected_cdf)

def testChi2Mean(self):
with tf.Session():
df_v = np.array([1., 3, 5], dtype=np.float64)
expected_mean = stats.chi2.mean(df_v)
chi2 = tf.contrib.distributions.Chi2(df=df_v)
self.assertEqual(chi2.mean.get_shape(), (3,))
self.assertAllClose(chi2.mean.eval(), expected_mean)

def testChi2Variance(self):
with tf.Session():
df_v = np.array([1., 3, 5], np.float64)
expected_variances = stats.chi2.var(df_v)
chi2 = tf.contrib.distributions.Chi2(df=df_v)
self.assertEqual(chi2.variance.get_shape(), (3,))
self.assertAllClose(chi2.variance.eval(), expected_variances)

def testChi2Entropy(self):
with tf.Session():
df_v = np.array([1., 3, 5], dtype=np.float64)
expected_entropy = stats.chi2.entropy(df_v)
chi2 = tf.contrib.distributions.Chi2(df=df_v)
self.assertEqual(chi2.entropy().get_shape(), (3,))
self.assertAllClose(chi2.entropy().eval(), expected_entropy)


if __name__ == '__main__':
tf.test.main()
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# Copyright 2016 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
"""Tests for initializers."""

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import numpy as np
from scipy import stats
import tensorflow as tf


class ExponentialTest(tf.test.TestCase):

def testExponentialLogPDF(self):
with tf.Session():
batch_size = 6
lam = tf.constant([2.0] * batch_size)
lam_v = 2.0
x = np.array([2.5, 2.5, 4.0, 0.1, 1.0, 2.0], dtype=np.float32)
exponential = tf.contrib.distributions.Exponential(lam=lam)
expected_log_pdf = stats.expon.logpdf(x, scale=1 / lam_v)

log_pdf = exponential.log_pdf(x)
self.assertEqual(log_pdf.get_shape(), (6,))
self.assertAllClose(log_pdf.eval(), expected_log_pdf)

pdf = exponential.pdf(x)
self.assertEqual(pdf.get_shape(), (6,))
self.assertAllClose(pdf.eval(), np.exp(expected_log_pdf))

def testExponentialCDF(self):
with tf.Session():
batch_size = 6
lam = tf.constant([2.0] * batch_size)
lam_v = 2.0
x = np.array([2.5, 2.5, 4.0, 0.1, 1.0, 2.0], dtype=np.float32)

exponential = tf.contrib.distributions.Exponential(lam=lam)
expected_cdf = stats.expon.cdf(x, scale=1 / lam_v)

cdf = exponential.cdf(x)
self.assertEqual(cdf.get_shape(), (6,))
self.assertAllClose(cdf.eval(), expected_cdf)

def testExponentialMean(self):
with tf.Session():
lam_v = np.array([1.0, 4.0, 2.5])
expected_mean = stats.expon.mean(scale=1 / lam_v)
exponential = tf.contrib.distributions.Exponential(lam=lam_v)
self.assertEqual(exponential.mean.get_shape(), (3,))
self.assertAllClose(exponential.mean.eval(), expected_mean)

def testExponentialVariance(self):
with tf.Session():
lam_v = np.array([1.0, 4.0, 2.5])
expected_variance = stats.expon.var(scale=1 / lam_v)
exponential = tf.contrib.distributions.Exponential(lam=lam_v)
self.assertEqual(exponential.variance.get_shape(), (3,))
self.assertAllClose(exponential.variance.eval(), expected_variance)

def testExponentialEntropy(self):
with tf.Session():
lam_v = np.array([1.0, 4.0, 2.5])
expected_entropy = stats.expon.entropy(scale=1 / lam_v)
exponential = tf.contrib.distributions.Exponential(lam=lam_v)
self.assertEqual(exponential.entropy().get_shape(), (3,))
self.assertAllClose(exponential.entropy().eval(), expected_entropy)


if __name__ == '__main__':
tf.test.main()
Loading

0 comments on commit 5ec60d9

Please sign in to comment.