Issue 1:
Please make sure that this is a bug. As per our GitHub Policy, we only address code/doc bugs, performance issues, feature requests and build/installation issues on GitHub. tag:bug_template

System information

Have I written custom code (as opposed to using a stock example script provided in TensorFlow):

OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Ubuntu 18.04

Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device: N/a

TensorFlow installed from (source or binary): binary

TensorFlow version (use command below): 2.0.0-beta0

Python version: 3.6

Bazel version (if compiling from source):

GCC/Compiler version (if compiling from source):

CUDA/cuDNN version: 10.0, 7.5

GPU model and memory: 11gb, GTX1080Ti

You can collect some of this information using our environment capture

script

You can also obtain the TensorFlow version with: 1. TF 1.0: python -c "import tensorflow as tf; print(tf.GIT_VERSION, tf.VERSION)" 2. TF 2.0: python -c "import tensorflow as tf; print(tf.version.GIT_VERSION, tf.version.VERSION)"

Describe the current behavior

I was using the code below with 1.12, 1.13.1 and tf2.0 alpha. But it fails to run in the latest tf2.0 beta. As you can see there is nothing fancy going on in the code. This is the block of code that produces this error

def ASPP(tensor):
'''atrous spatial pyramid pooling'''
dims = K.int_shape(tensor)

y_pool = AveragePooling2D(pool_size=(
dims[1], dims[2]), name='average_pooling')(tensor)
y_pool = Conv2D(filters=256, kernel_size=1, padding='same',
kernel_initializer='he_normal', name='pool_1x1conv2d', use_bias=False)(y_pool)
y_pool = BatchNormalization(name=f'bn_1')(y_pool)
y_pool = Activation('relu', name=f'relu_1')(y_pool)

y_pool = Upsample(tensor=y_pool, size=[dims[1], dims[2]])

y_1 = Conv2D(filters=256, kernel_size=1, dilation_rate=1, padding='same',
kernel_initializer='he_normal', name='ASPP_conv2d_d1', use_bias=False)(tensor)
y_1 = BatchNormalization(name=f'bn_2')(y_1)
y_1 = Activation('relu', name=f'relu_2')(y_1)

y_6 = Conv2D(filters=256, kernel_size=3, dilation_rate=6, padding='same',
kernel_initializer='he_normal', name='ASPP_conv2d_d6', use_bias=False)(tensor)
y_6 = BatchNormalization(name=f'bn_3')(y_6)
y_6 = Activation('relu', name=f'relu_3')(y_6)

y_12 = Conv2D(filters=256, kernel_size=3, dilation_rate=12, padding='same',
kernel_initializer='he_normal', name='ASPP_conv2d_d12', use_bias=False)(tensor)
y_12 = BatchNormalization(name=f'bn_4')(y_12)
y_12 = Activation('relu', name=f'relu_4')(y_12)

y_18 = Conv2D(filters=256, kernel_size=3, dilation_rate=18, padding='same',
kernel_initializer='he_normal', name='ASPP_conv2d_d18', use_bias=False)(tensor)
y_18 = BatchNormalization(name=f'bn_5')(y_18)
y_18 = Activation('relu', name=f'relu_5')(y_18)

y = concatenate([y_pool, y_1, y_6, y_12, y_18], name='ASPP_concat')

y = Conv2D(filters=256, kernel_size=1, dilation_rate=1, padding='same',
kernel_initializer='he_normal', name='ASPP_conv2d_final', use_bias=False)(y)
y = BatchNormalization(name=f'bn_final')(y)
y = Activation('relu', name=f'relu_final')(y)
return y

Strangely shapes of y_pool, y_1 are correctly inferred , complete code to reproduce the issue available below

y = concatenate([y_pool, y_1, y_6, y_12, y_18], name='ASPP_concat')

Describe the expected behavior

The code should work as it did in the earlier release ie tf2.0 alpha

Code to reproduce the issue

import tensorflow as tf
from tensorflow.keras import backend as K
from tensorflow.keras.models import Model
from tensorflow.keras.layers import AveragePooling2D, Lambda, Conv2D, Conv2DTranspose, Activation, Reshape, concatenate, Concatenate, BatchNormalization, ZeroPadding2D
from tensorflow.keras.applications.resnet50 import ResNet50

def Upsample(tensor, size):
'''bilinear upsampling'''
name = tensor.name.split('/')[0] + '_upsample'

def bilinear_upsample(x, size):
resized = tf.image.resize(
images=x, size=size)
return resized
y = Lambda(lambda x: bilinear_upsample(x, size),
output_shape=size, name=name)(tensor)
return y

def ASPP(tensor):
'''atrous spatial pyramid pooling'''
dims = K.int_shape(tensor)

y_pool = AveragePooling2D(pool_size=(
dims[1], dims[2]), name='average_pooling')(tensor)
y_pool = Conv2D(filters=256, kernel_size=1, padding='same',
kernel_initializer='he_normal', name='pool_1x1conv2d', use_bias=False)(y_pool)
y_pool = BatchNormalization(name=f'bn_1')(y_pool)
y_pool = Activation('relu', name=f'relu_1')(y_pool)

y_pool = Upsample(tensor=y_pool, size=[dims[1], dims[2]])

y_1 = Conv2D(filters=256, kernel_size=1, dilation_rate=1, padding='same',
kernel_initializer='he_normal', name='ASPP_conv2d_d1', use_bias=False)(tensor)
y_1 = BatchNormalization(name=f'bn_2')(y_1)
y_1 = Activation('relu', name=f'relu_2')(y_1)

y_6 = Conv2D(filters=256, kernel_size=3, dilation_rate=6, padding='same',
kernel_initializer='he_normal', name='ASPP_conv2d_d6', use_bias=False)(tensor)
y_6 = BatchNormalization(name=f'bn_3')(y_6)
y_6 = Activation('relu', name=f'relu_3')(y_6)

y_12 = Conv2D(filters=256, kernel_size=3, dilation_rate=12, padding='same',
kernel_initializer='he_normal', name='ASPP_conv2d_d12', use_bias=False)(tensor)
y_12 = BatchNormalization(name=f'bn_4')(y_12)
y_12 = Activation('relu', name=f'relu_4')(y_12)

y_18 = Conv2D(filters=256, kernel_size=3, dilation_rate=18, padding='same',
kernel_initializer='he_normal', name='ASPP_conv2d_d18', use_bias=False)(tensor)
y_18 = BatchNormalization(name=f'bn_5')(y_18)
y_18 = Activation('relu', name=f'relu_5')(y_18)

y = concatenate([y_pool, y_1, y_6, y_12, y_18], name='ASPP_concat')

y = Conv2D(filters=256, kernel_size=1, dilation_rate=1, padding='same',
kernel_initializer='he_normal', name='ASPP_conv2d_final', use_bias=False)(y)
y = BatchNormalization(name=f'bn_final')(y)
y = Activation('relu', name=f'relu_final')(y)
return y

def DeepLabV3Plus(img_height, img_width):
base_model = ResNet50(input_shape=(
img_height, img_width, 3), weights='imagenet', include_top=False)

image_features = base_model.get_layer('activation_39').output
x_a = ASPP(image_features)
x_a = Upsample(tensor=x_a, size=[img_height // 4, img_width // 4])

x_b = base_model.get_layer('activation_9').output
x_b = Conv2D(filters=48, kernel_size=1, padding='same',
kernel_initializer='he_normal', name='low_level_projection', use_bias=False)(x_b)
x_b = BatchNormalization(name=f'bn_low_level_projection')(x_b)
x_b = Activation('relu', name='low_level_activation')(x_b)

x = concatenate([x_a, x_b], name='decoder_concat')

x = Conv2D(filters=256, kernel_size=3, padding='same', activation='relu',
kernel_initializer='he_normal', name='decoder_conv2d_1', use_bias=False)(x)
x = BatchNormalization(name=f'bn_decoder_1')(x)
x = Activation('relu', name='activation_decoder_1')(x)

x = Conv2D(filters=256, kernel_size=3, padding='same', activation='relu',
kernel_initializer='he_normal', name='decoder_conv2d_2', use_bias=False)(x)
x = BatchNormalization(name=f'bn_decoder_2')(x)
x = Activation('relu', name='activation_decoder_2')(x)
x = Upsample(x, [img_height, img_width])

x = Conv2D(1, (1, 1), name='output_layer')(x)
x = Activation('sigmoid')(x)
model = Model(inputs=base_model.input, outputs=x, name='DeepLabV3_Plus')
return model

Other info / logs

ValueError Traceback (most recent call last)
<ipython-input-20-0876af914f24> in <module>()
----> 1 DeepLabV3Plus(512, 512)

6 frames
/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/layers/merge.py in build(self, input_shape)
389 'inputs with matching shapes '
390 'except for the concat axis. '
--> 391 'Got inputs shapes: %s' % (input_shape))
392
393 def _merge_function(self, inputs):

ValueError: A `Concatenate` layer requires inputs with matching shapes except for the concat axis. Got inputs shapes: [(None, 32, 32, 256), (None, 32, 32, 256), (None, None, None, 256), (None, None, None, 256), (None, None, None, 256)]

Issue 2:
System information

Ubuntu 18.04, Tensorflow r2.0 from pip

Describe the current behavior

https://github.com/tensorflow/tensorflow/blob/r2.0/tensorflow/core/kernels/non_max_suppression_op.cu.cc#L96

Describe the expected behavior

const float w = fdimf(xx2, xx1);
const float h = fdimf(yy2, yy1);
const float intersection = w * h;

Code to reproduce the issue

I believe that the calculation of intersection over union in line 96 of the GPU implementation of non-max suppression is incorrect.

boxes = np.array([[0.2, 0.3, 0.4, 0.5], [0.61, 0.71, 0.81, 0.91], [0.6, 0.7, 0.8, 0.9]], dtype=np.float32)
score = np.array([0.2, 0.7, 0.6], dtype=np.float32)
iou_threshold = 0.5
nms_reference_cpu = tf.image.non_max_suppression(
boxes=boxes,
scores=score,
max_output_size=3,
iou_threshold=0.5,
)
= [1, 0]

it will not work for GPU, but it will work for CPU. If you remove the +1 (not sure why you would want to do that in the first place), they match.

Other info / logs

Include any logs or source code that would be helpful to diagnose the problem. If including tracebacks, please include the full traceback. Large logs and files should be attached.