TensorFlow错误:TypeError: __init__() got an unexpected keyword argument 'serialized_options'

用了好久的时间搞定了机器学习,今天想搞一搞深度学习,用TensorFlow的过程中却遇到了错误:

Traceback (most recent call last):
  File "F:/编程/python/python人工智能/python就业/深度学习/TensorFlow基础/Tensorflow初体验.py", line 1, in <module>
    import tensorflow as tf
  File "D:\Python\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
    from tensorflow.python import pywrap_tensorflow  # pylint: disable=unused-import
  File "D:\Python\lib\site-packages\tensorflow\python\__init__.py", line 52, in <module>
    from tensorflow.core.framework.graph_pb2 import *
  File "D:\Python\lib\site-packages\tensorflow\core\framework\graph_pb2.py", line 15, in <module>
    from tensorflow.core.framework import node_def_pb2 as tensorflow_dot_core_dot_framework_dot_node__def__pb2
  File "D:\Python\lib\site-packages\tensorflow\core\framework\node_def_pb2.py", line 15, in <module>
    from tensorflow.core.framework import attr_value_pb2 as tensorflow_dot_core_dot_framework_dot_attr__value__pb2
  File "D:\Python\lib\site-packages\tensorflow\core\framework\attr_value_pb2.py", line 15, in <module>
    from tensorflow.core.framework import tensor_pb2 as tensorflow_dot_core_dot_framework_dot_tensor__pb2
  File "D:\Python\lib\site-packages\tensorflow\core\framework\tensor_pb2.py", line 15, in <module>
    from tensorflow.core.framework import resource_handle_pb2 as tensorflow_dot_core_dot_framework_dot_resource__handle__pb2
  File "D:\Python\lib\site-packages\tensorflow\core\framework\resource_handle_pb2.py", line 22, in <module>
    serialized_pb=_b('\n/tensorflow/core/framework/resource_handle.proto\x12\ntensorflow\"r\n\x13ResourceHandleProto\x12\x0e\n\x06\x64\x65vice\x18\x01 \x01(\t\x12\x11\n\tcontainer\x18\x02 \x01(\t\x12\x0c\n\x04name\x18\x03 \x01(\t\x12\x11\n\thash_code\x18\x04 \x01(\x04\x12\x17\n\x0fmaybe_type_name\x18\x05 \x01(\tBn\n\x18org.tensorflow.frameworkB\x0eResourceHandleP\x01Z=github.com/tensorflow/tensorflow/tensorflow/go/core/framework\xf8\x01\x01\x62\x06proto3')
TypeError: __init__() got an unexpected keyword argument 'serialized_options'

历时两个小时,终于解决了。

问题其实很简单,TensorFlow和protobuf的版本不匹配,

我的TensorFlow和protobuf版本:

tensorflow                         1.13.0rc1

protobuf                           3.1.0

tensorflow 1.13.0rc1需要的是protobuf 3.6.1,所以不匹配,

具体的解决步骤:

pip3 uninstall protobuf 

pip3 uninstall tensorflow

pip3 install tensorflow

新的问题

paddlepaddle,百度自主研发,真正源于产业实践,易学易用,安全高效分布式深度学习框架。
paddlepaddle 1.2.1 has requirement protobuf==3.1
很头疼,两个深度学习框架需要的protobuf版本不一样。

所以,自己决定吧。

(支持国产)

posted @ 2019-02-15 17:33  AlexKing007  阅读(51)  评论(0编辑  收藏  举报