错误“Numpy.ndarray 大小已更改,可能表明二进制不兼容。预期来自 C 标头的值为 88,但从 PyObject 得到的值为 80。”

pip*_*el1 7 python numpy tensorflow

我在遵循本教程时收到此错误文件:https://www.youtube.com/watch ?v=yqkISICHH-U

到目前为止,我已经创建了一个训练数据集来输入 Tensorflow。我正在预训练的 TensorFlow 对象识别模型之一上使用迁移学习。当我尝试使用新数据集训练模型时出现错误。这是显示的完整错误消息的图片

我试图通过尝试以下方法来解决该问题:

  • 重新安装 Numpy
  • 安装 Numpy 1.20.x
  • 安装 Numpy 1.18.x
  • 重新安装 pycocotools

当我安装 Numpy 1.20.x 时,错误消失并被一个单独的错误替换:notimplementederror:无法将符号张量(cond_2/strided:0)转换为 numpy 数组。这似乎是 Tensorflow 和 Numpy 1.20.x 之间的兼容性问题。在调试这个错误时,我发现每个人都通过将 Numpy 降级到 1.19.x 来解决它。然而,就我而言,我仍然遇到第一个错误。

我正在使用 python 3.8.9 和 anaconda。以下是我安装的软件包:https://pastebin.com/BNW8tU2A

(tfod) (base) C:\Users\piper\python\Tensorflow\TFODCourse>pip list
Package                 Version             Location
----------------------- ------------------- ---------------------------------------------------------------------------
absl-py                 0.13.0
astunparse              1.6.3
backcall                0.2.0
cachetools              4.2.2
certifi                 2021.5.30
charset-normalizer      2.0.3
colorama                0.4.4
cycler                  0.10.0
Cython                  0.29.24
debugpy                 1.3.0
decorator               5.0.9
flatbuffers             1.12
gast                    0.4.0
gin-config              0.4.0
google-auth             1.33.1
google-auth-oauthlib    0.4.4
google-cloud-bigquery   1.21.0
google-pasta            0.2.0
grpcio                  1.34.1
h5py                    3.1.0
idna                    3.2
ipykernel               6.0.3
ipython                 7.25.0
ipython-genutils        0.2.0
jedi                    0.18.0
jupyter-client          6.1.12
jupyter-core            4.7.1
keras-nightly           2.5.0.dev2021032900
Keras-Preprocessing     1.1.2
kiwisolver              1.3.1
lvis                    0.5.3
lxml                    4.6.3
Markdown                3.3.4
matplotlib              3.2.0
matplotlib-inline       0.1.2
numpy                   1.19.5
oauthlib                3.1.1
object-detection        0.1
opencv-python           4.5.3.56
opt-einsum              3.3.0
pandas                  1.3.0
parso                   0.8.2
pickleshare             0.7.5
Pillow                  8.3.1
pip                     21.1.3
prompt-toolkit          3.0.19
protobuf                3.17.3
pyasn1                  0.4.8
pyasn1-modules          0.2.8
pycocotools             2.0.2
Pygments                2.9.0
pyparsing               2.4.7
PyQt5                   5.15.4
PyQt5-Qt5               5.15.2
PyQt5-sip               12.9.0
python-dateutil         2.8.2
pytz                    2021.1
pywin32                 225
PyYAML                  5.4.1
pyzmq                   22.1.0
requests                2.26.0
requests-oauthlib       1.3.0
rsa                     4.7.2
scipy                   1.7.0
setuptools              49.2.1
six                     1.15.0
slim                    0.1                 c:\users\piper\python\tensorflow\tfodcourse\tensorflow\models\research\slim
tensorboard             2.5.0
tensorboard-data-server 0.6.1
tensorboard-plugin-wit  1.8.0
tensorflow              2.5.0
tensorflow-addons       0.13.0
tensorflow-estimator    2.5.0
tensorflow-gpu          2.5.0
termcolor               1.1.0
tf-models-official      2.5.0
tf-slim                 1.1.0
tornado                 6.1
traitlets               5.0.5
typeguard               2.12.1
typing-extensions       3.7.4.3
urllib3                 1.26.6
wcwidth                 0.2.5
Werkzeug                2.0.1
wget                    3.2
wheel                   0.36.2
wrapt                   1.12.1
Run Code Online (Sandbox Code Playgroud)

任何帮助,将不胜感激!

所以我通过使用 --no-cache-dir 标志重新安装 pycocotools 解决了这个问题。所以我做了:

pip uninstall pycocotools
pip install --no-cache-dir pycocotools
Run Code Online (Sandbox Code Playgroud)

这彻底解决了这个问题。

Yon*_*son 1

我在虚拟环境中使用python3.6也遇到了同样的问题。使用--no-cache-dir标志重新安装并没有解决问题。

我通过在虚拟环境中使用 python3.7 从头开始​​解决了这个问题