System information
- Have I written custom code (as opposed to using a stock example script provided in TensorFlow): yes
- OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Linux 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.6.0
- Python version: 3.6.8
- Bazel version (if compiling from source): n/a
- GCC/Compiler version (if compiling from source): n/a
- CUDA/cuDNN version: n/a
- GPU model and memory: n/a
Describe the current behavior
tf.keras.layers.MaxPooling3D crashes when pool_size contains 0, and outputs a all-inf tensor when pool_size contains negative values.
Describe the expected behavior
Expect a ValueError to be thrown if the input pool_size contains zero or negative values.
Standalone code to reproduce the issue
If the pool_size has 0:
import tensorflow as tf
pool_size = [2, 2, 0]
layer = tf.keras.layers.MaxPooling3D(strides=1, pool_size=pool_size)
input_tensor = tf.random.uniform([3, 4, 10, 11, 12], dtype=tf.float32)
res = layer(input_tensor) # crash
Outputs:
Floating point exception (core dumped)
If the pool_size has negative values:
import tensorflow as tf
pool_size = [2, 2, -2]
layer = tf.keras.layers.MaxPooling3D(strides=1, pool_size=pool_size,)
input_tensor = tf.random.uniform([3, 4, 10, 11, 12], dtype=tf.float32)
res = layer(input_tensor)
print(res)
The output is a tensor with shape=(3, 3, 9, 14, 12) and all inf values.
System information
Describe the current behavior
tf.keras.layers.MaxPooling3Dcrashes whenpool_sizecontains0, and outputs a all-inf tensor whenpool_sizecontains negative values.Describe the expected behavior
Expect a
ValueErrorto be thrown if the inputpool_sizecontains zero or negative values.Standalone code to reproduce the issue
If the
pool_sizehas0:Outputs:
If the
pool_sizehas negative values:The output is a tensor with
shape=(3, 3, 9, 14, 12)and allinfvalues.