Thanks to visit codestin.com
Credit goes to github.com

Skip to content

tf.keras.layers.MaxPooling3D crashes #51936

@lugalUrim

Description

@lugalUrim

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.

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions