tensorflow: [BUG] Default MaxPoolingOp/AvgPoolingOp only supports NHWC
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 CentOS 7
- TensorFlow installed from (source or binary): pip install tensorflow with virtualEnv
- TensorFlow version (use command below): 1.4.0
- Python version: 2.7.5
- Exact command to reproduce:
import numpy as np
import tensorflow as tf
a = tf.nn.max_pool(np.random.rand(1, 1,10,10), [1,1,2,2], [1,1,1,1], 'VALID', data_format='NCHW')
sess=tf.InteractiveSession()
sess.run(a)
Describe the problem
When I try to run a node of type max or avg pool with data_format : ‘NCHW’ I got an error. This seems to be a bug because the TF docs affirms that :
data_format: A string. ‘NHWC’, ‘NCHW’ and ‘NCHW_VECT_C’ are supported.
Error logs
With max:
2017-12-14 12:40:23.250331: E tensorflow/core/common_runtime/executor.cc:643] Executor failed to create kernel. Invalid argument: Default MaxPoolingOp only supports NHWC. [[Node: MaxPool = MaxPoolT=DT_DOUBLE, data_format=“NCHW”, ksize=[1, 1, 2, 2], padding=“VALID”, strides=[1, 1, 1, 1], _device=“/job:localhost/replica:0/task:0/device:CPU:0”]]
With Avg:
tensorflow.python.framework.errors_impl.InvalidArgumentError: Default AvgPoolingOp only supports NHWC. [[Node: AvgPool_1 = AvgPoolT=DT_FLOAT, data_format=“NCHW”, ksize=[1, 1, 2, 2], padding=“VALID”, strides=[1, 1, 1, 1], _device=“/job:localhost/replica:0/task:0/device:CPU:0”]]
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 17 (7 by maintainers)
Just to clear some potential confusion around this. If you compile tensorflow with MKL support you can use these ops with
NCHW.I tried all the aforementioed methods. nevertheless of these methods were overcome this bug. I still have had the same issue: InvalidArgumentError: Default MaxPoolingOp only supports NHWC on device type CPU [[{{node max_pooling2d_2/MaxPool}}]]
When I trying to execute this code in jupyter notebooke:
Training
hist = model.fit(X_train, y_train, batch_size=16, epochs=num_epoch, verbose=1, validation_data=(X_test, y_test)) Pleasem I need your support
I think you are getting this error because of the code you provided. You are trying to max pool from numpy array. When I run your code I got the same error. When modified it is working properly.
@zheng-xq Thanks. @ dr4b Can we update the documentation on nn_ops.py for function “max_pool”?