TypeError: Parameter to MergeFrom() must be instance of same class: expected TensorShapeProto got TensorShapeProto.
- 本机配置:
- 系统:macOS Monterey(M2芯片) 12.5.1
- Python:3.9.12
- tensorflow: 2.6.0
解决方法
- 找到下面的文件
/opt/anaconda3/envs/tensorflow/lib/python3.9/site-packages/tensorflow/python/__init__.py
- 更改其中的两条代码顺序
文件内源代码为:
from tensorflow.python.eager import context
from tensorflow.python import pywrap_tensorflow as _pywrap_tensorflow
交换后如下:
from tensorflow.python import pywrap_tensorflow as _pywrap_tensorflow
from tensorflow.python.eager import context
更改两条语句顺序后就可以成功运行了!