Tensorflow Protobuf不兼容

发布于 2025-02-07 08:09:56 字数 1057 浏览 0 评论 0原文

由于原始不兼容,我无法使张量变量变得可行。感谢是否有人建议如何修复它。

以下是错误:

$ python a.py
Traceback (most recent call last):
  File "a.py", line 20, in <module>
    a = tf.Variable(tf.zeros(2))
  File "/opt/miniconda3/lib/python3.8/site-packages/tensorflow/python/util/traceback_utils.py", line 153, in error_handler
    raise e.with_traceback(filtered_tb) from None
  File "/opt/miniconda3/lib/python3.8/site-packages/tensorflow/python/ops/resource_variable_ops.py", line 177, in _variable_handle_from_shape_and_dtype
    handle_data.shape_and_type.append(
AttributeError: 'google.protobuf.pyext._message.RepeatedCompositeCo' object has no attribute 'append'
(base) kanduru@SJC-L-00060215:/mnt/c/Users/kanduru/Documents/Courses/MIT/skunk/Auto-Surprise$

代码是

import tensorflow as tf

a = tf.Variable(tf.zeros(2))
$ pip list | grep tensorflow
tensorflow                        2.7.0
tensorflow-estimator              2.7.0
$ pip list | grep protobuf
protobuf                          4.21.1

I could not get the tensorflow Variables to work because of protobuf incompatibility. Appreciate if someone can suggest how to fix it.

The following is the error:

$ python a.py
Traceback (most recent call last):
  File "a.py", line 20, in <module>
    a = tf.Variable(tf.zeros(2))
  File "/opt/miniconda3/lib/python3.8/site-packages/tensorflow/python/util/traceback_utils.py", line 153, in error_handler
    raise e.with_traceback(filtered_tb) from None
  File "/opt/miniconda3/lib/python3.8/site-packages/tensorflow/python/ops/resource_variable_ops.py", line 177, in _variable_handle_from_shape_and_dtype
    handle_data.shape_and_type.append(
AttributeError: 'google.protobuf.pyext._message.RepeatedCompositeCo' object has no attribute 'append'
(base) kanduru@SJC-L-00060215:/mnt/c/Users/kanduru/Documents/Courses/MIT/skunk/Auto-Surprise$

and the code is

import tensorflow as tf

a = tf.Variable(tf.zeros(2))
$ pip list | grep tensorflow
tensorflow                        2.7.0
tensorflow-estimator              2.7.0
$ pip list | grep protobuf
protobuf                          4.21.1

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

早乙女 2025-02-14 08:09:56

tensorflow安装或Tensorflow版本与现有库的兼容性可能存在问题。 Protobuf在安装TensorFlow时,将其与特定版本与Tensorflow版本兼容。

您可以使用以下代码将Tensorflow版本升级到最新版本,请再次尝试:

pip install --upgrade pip
pip install --upgrade tensorflow #or 
pip install tensorflow==2.10 

请查看此 tensorflow安装指南有关更多详细信息。
让我们知道问题是否仍然存在。谢谢。

There could be an issue with the TensorFlow installation or TensorFlow version compatibility with existing libraries. protobuf gets installed itself with its specific version compatible to Tensorflow version while installing TensorFlow.
enter image description here

Could you please try again by upgrading the TensorFlow version to the latest version using the code below:

pip install --upgrade pip
pip install --upgrade tensorflow #or 
pip install tensorflow==2.10 

Please have a look at this Tensorflow install guide for more details.
Let us know if the issue still persists. Thank you.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文