From 9fe71e08a56035dd547f7f9e9f7fdc0b093d0c96 Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Fri, 1 Sep 2017 12:07:05 -0700 Subject: Adding back contrib.receptive_field test to oss. PiperOrigin-RevId: 167307311 --- tensorflow/contrib/receptive_field/BUILD | 3 --- tensorflow/contrib/receptive_field/README.md | 3 ++- .../contrib/receptive_field/python/util/receptive_field.py | 10 +++++++--- 3 files changed, 9 insertions(+), 7 deletions(-) (limited to 'tensorflow') diff --git a/tensorflow/contrib/receptive_field/BUILD b/tensorflow/contrib/receptive_field/BUILD index e2d7c07510..ed2f3af08c 100644 --- a/tensorflow/contrib/receptive_field/BUILD +++ b/tensorflow/contrib/receptive_field/BUILD @@ -47,9 +47,6 @@ py_test( name = "receptive_field_test", srcs = ["python/util/receptive_field_test.py"], srcs_version = "PY2AND3", - tags = [ - "no_oss", # see b/65254194 - ], deps = [ ":receptive_field_py", "//tensorflow/contrib/framework:framework_py", diff --git a/tensorflow/contrib/receptive_field/README.md b/tensorflow/contrib/receptive_field/README.md index f7539ec145..b150b903b2 100644 --- a/tensorflow/contrib/receptive_field/README.md +++ b/tensorflow/contrib/receptive_field/README.md @@ -161,4 +161,5 @@ Effective padding (vertical) = 1482 ## Authors -André Araujo (andrefaraujo@) and Mark Sandler +André Araujo (github id: andrefaraujo) and Mark Sandler (github id: +marksandler) diff --git a/tensorflow/contrib/receptive_field/python/util/receptive_field.py b/tensorflow/contrib/receptive_field/python/util/receptive_field.py index 4e723829bf..db190a1a41 100644 --- a/tensorflow/contrib/receptive_field/python/util/receptive_field.py +++ b/tensorflow/contrib/receptive_field/python/util/receptive_field.py @@ -35,6 +35,10 @@ _UNCHANGED_RF_LAYER_OPS = [ "VariableV2", "Sub", "Rsqrt", "ConcatV2" ] +# Different ways in which padding modes may be spelled. +_VALID_PADDING = ["VALID", b"VALID"] +_SAME_PADDING = ["SAME", b"SAME"] + def _stride_size(node): """Computes stride size given a TF node. @@ -102,9 +106,9 @@ def _padding_size_conv_pool(node, kernel_size, stride): # depends on input size, we raise an exception. padding_attr = node.attr["padding"] logging.vlog(4, "padding_attr = %s", padding_attr) - if padding_attr.s == "VALID": + if padding_attr.s in _VALID_PADDING: padding = 0 - elif padding_attr.s == "SAME": + elif padding_attr.s in _SAME_PADDING: if kernel_size == 1: padding = 0 elif stride == 1: @@ -118,7 +122,7 @@ def _padding_size_conv_pool(node, kernel_size, stride): "padding may be different depending on the input image " "dimensionality. In this case, alignment check will be skipped.") else: - raise ValueError("Invalid padding operation") + raise ValueError("Invalid padding operation %s" % padding_attr.s) return padding -- cgit v1.2.3