aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/contrib/specs
diff options
context:
space:
mode:
authorGravatar Justine Tunney <jart@google.com>2016-12-14 12:38:08 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2016-12-14 12:46:03 -0800
commitf6917c6514aadae9b3fbd2ad7a0ece8f2f9f659f (patch)
tree6162396356fa01705ce7ae1da108de185c83c997 /tensorflow/contrib/specs
parent48191da012d73eea3a322d839cc279ae976e67d7 (diff)
Remove contrib.specs AutoFunction
This does clever things with the TensorFlow namespaces which we can't maintain. Change: 142050311
Diffstat (limited to 'tensorflow/contrib/specs')
-rw-r--r--tensorflow/contrib/specs/README.md19
-rw-r--r--tensorflow/contrib/specs/python/specs_lib.py51
-rw-r--r--tensorflow/contrib/specs/python/specs_ops.py8
-rw-r--r--tensorflow/contrib/specs/python/specs_test.py13
4 files changed, 0 insertions, 91 deletions
diff --git a/tensorflow/contrib/specs/README.md b/tensorflow/contrib/specs/README.md
index e2c6c5c8bc..7ed6569ed8 100644
--- a/tensorflow/contrib/specs/README.md
+++ b/tensorflow/contrib/specs/README.md
@@ -207,25 +207,6 @@ actually just values placed in the namespace somehow. The `Import`
function takes an arbitrary Python statement that eventually needs to
assign a value to the variable `f` that is then wrapped up as a function.
-# AutoFunction
-
-Not all functions available in TensorFlow have corresponding short names
-in specs; in order to access other functions conveniently, you can refer
-to any function in a number of existing modules using the full function
-name in that module. Module shortcuts are defined for:
-
- - `TF` = `tf`
- - `NN` = `tf.nn`
- - `SL` = `slim`
-
-You can, of course, introduce more abbreviations in your own code.
-
-These are defined as:
-
- TF = specs_lib.AutoFunction(tf)
-
-Using these definitions, `SL.conv2d(64, 5)` is equivalent to `Cr(64, 5)`.
-
# Summaries
There are a number of functions that give you information about the structure
diff --git a/tensorflow/contrib/specs/python/specs_lib.py b/tensorflow/contrib/specs/python/specs_lib.py
index e2ddd7567e..12663c2788 100644
--- a/tensorflow/contrib/specs/python/specs_lib.py
+++ b/tensorflow/contrib/specs/python/specs_lib.py
@@ -169,57 +169,6 @@ class Function(Composable):
return self.f(x, *args, **kw)
-class AutoFunction(object):
- """Automatically curry functions when accessed as attributes.
-
- This class wraps a dictionary mapping keys to values. When an attribute
- is accessed, the class looks up the attribute in the dictionary and
- wraps it (curries it) using Function(...). When wrapped around
- existing modules implementing TensorFlow functions or layers, this
- turns those functions or layers automatically into specs-compatible
- layers.
-
- For example, `net` and `net2` are equivalent:
- TF = AutoFunction(tf)
- with specs.ops:
- net = TF.conv2d(64, 5) ** 3 | Flat
- net2 = Cr(64, 5) ** 3 | Flat
-
- Attributes:
- source: A dictionary holding the underlying key-value mappings.
- """
-
- def __init__(self, source):
- """Creates an AutoFunction wrapper for a module.
-
- Args:
- source: A dictionary or a module.
- """
- if not isinstance(source, dict):
- source = vars(source)
- self.source = source
-
- def __getattr__(self, key):
- """Looks up the key in the source dictionary and curries the result.
-
- Args:
- key: The symbol name to look up.
-
- Returns:
- The curried argument.
-
- Raises:
- ValueError: The key does not exist, or it doesn't refer to a callable.
- """
- result = self.source.get(key, None)
- if result is None:
- raise ValueError("%s: no such symbol")
- if not callable(result):
- raise ValueError("value of %s is not callable (type is %s)" %
- (key, type(result)))
- return Function(result)
-
-
class Composition(Composable):
"""A function composition.
diff --git a/tensorflow/contrib/specs/python/specs_ops.py b/tensorflow/contrib/specs/python/specs_ops.py
index 5658fc3e98..241de5458b 100644
--- a/tensorflow/contrib/specs/python/specs_ops.py
+++ b/tensorflow/contrib/specs/python/specs_ops.py
@@ -235,11 +235,3 @@ class Shared(specs_lib.Composable):
else:
with tf.variable_scope(self.scope, values=[x], reuse=True):
return self.subnet.funcall(x)
-
-# AutoFunction bindings of some existing modules
-
-TF = specs_lib.AutoFunction(tf)
-NN = specs_lib.AutoFunction(tf.nn)
-SL = specs_lib.AutoFunction(slim)
-
-# pylint: enable=invalid-name
diff --git a/tensorflow/contrib/specs/python/specs_test.py b/tensorflow/contrib/specs/python/specs_test.py
index 67e4a559a9..b9ddfc4658 100644
--- a/tensorflow/contrib/specs/python/specs_test.py
+++ b/tensorflow/contrib/specs/python/specs_test.py
@@ -213,19 +213,6 @@ class SpecsTest(tf.test.TestCase):
_ = g.funcall(inputs)
self.assertEqual(len(tf.global_variables()), 2)
- def testAutoFunction(self):
- with self.test_session():
- inputs = tf.constant(_rand(1, 18, 19, 5))
- with specs.ops:
- # pylint: disable=undefined-variable
- net = SL.conv2d(64, 5)
- outputs = net.funcall(inputs)
- self.assertEqual(outputs.get_shape().as_list(), [1, 18, 19, 64])
- tf.global_variables_initializer().run()
- result = outputs.eval()
- self.assertEqual(tuple(result.shape), (1, 18, 19, 64))
- self.assertEqual(summaries.tf_spec_structure("net = Cr(64, 5)", inputs),
- "_ var conv var biasadd relu")
if __name__ == "__main__":
tf.test.main()