Closed ShobiPr closed 3 years ago
So that error comes from using older versions of tensorflow-cpu (<2.0.0). I did a quick check to see if newer versions of tensorflow are affected and it appears this is no longer an issue if you're using tensorflow >=2.0.0.
If you're using Anaconda's python distribution (https://www.anaconda.com/distribution/) then you can install the CPU version of tensorflow (currently 2.0.0) with conda:
conda install tensorflow
I don't know if this is true if you install tensorflow with pip; I know that the version installed with conda is compiled against an optimized BLAS so perhaps there could be other differences with the pip package versus the conda package. Which version of tensorflow are you using and how was it installed?
I used tensorflow version 1.15.0 and installed it using pip3. I now tried with tensorflow version 2.1.0 (installed using pip3) and getting this error message:
tensorflow.python.framework.errors_impl.InvalidArgumentError: Default AvgPoolingOp only supports NHWC on device type CPU [[node model/average_pooling2d/AvgPool (defined at /Users/****/Desktop/cnn/test.py:124) ]] [Op:__inference_distributed_function_1921] Function call stack: distributed_function
OK I can recreate the error message you reported for tensorflow 2.0.0 as well when installed through pip so this points to differences in the conda package vs the pip package and how they are compiled and configured.
So the situation is:
If none of these options are available to you, a very hacky last-resort, and something I do not recommend doing for numerous reasons, is to replace the AveragePooling2D layer with a DepthwiseConv2D layer with no bias and with kernel size and stride equal to the size of the pooling layer. Meaning for example:
AveragePooling2D(pool_size=(1,4))
would be something like
DepthwiseConv2D(kernel_size=(1,4), strides=(1,4), bias=False)
then set that layer's weights using .set_weights()
equal to (1/K) where K is the length of the kernel. This should in theory work but I've never tested this and it may have weird edge cases (for example if you're using padding = 'same' vs 'causal' vs 'valid'). So I definitely wouldn't pursue this unless you're willing to validate it.
Another alternative and maybe the easiest, is to install intel-tensorflow
with pip.
I uninstalled tensorflow and reinstalled it through Anaconda and it worked! Thanks for the help!
good to hear! I'll leave this open so that other users can find it easier. Let me know if there are other issues.
Hi,
I'm getting this error message when testing the code:
Is it possible to run EEGNet without GPU?