InvalidArgumentError (see above for traceback): NodeDef mentions attr 'identical_element_shapes' not

    When I run real_time_counting.py,this error occurred:
    2019-08-11 14:15:08.854541: E tensorflow/core/common_runtime/executor.cc:644] Executor failed to create kernel. Invalid argument: NodeDef mentions attr 'identical_element_shapes' not in Op<name=TensorArrayV3; signature=size:int32 -> handle:resource, flow:float; attr=dtype:type; attr=element_shape:shape,default=; attr=dynamic_size:bool,default=false; attr=clear_after_read:bool,default=true; attr=tensor_array_name:string,default=""; is_stateful=true>; NodeDef: Preprocessor/map/TensorArray = TensorArrayV3clear_after_read=true, dtype=DT_FLOAT, dynamic_size=false, element_shape=, identical_element_shapes=true, tensor_array_name="", _device="/job:localhost/replica:0/task:0/cpu:0". (Check whether your GraphDef-interpreting binary is up to date with your GraphDef-generating binary.).
    [[Node: Preprocessor/map/TensorArray = TensorArrayV3clear_after_read=true, dtype=DT_FLOAT, dynamic_size=false, element_shape=, identical_element_shapes=true, tensor_array_name="", _device="/job:localhost/replica:0/task:0/cpu:0"]]
    Traceback (most recent call last):
    File "/home/lf/anaconda3/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1327, in _do_call
    return fn(*args)
    File "/home/lf/anaconda3/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1306, in _run_fn
    status, run_metadata)
    File "/home/lf/anaconda3/lib/python3.6/contextlib.py", line 88, in exit
    next(self.gen)
    File "/home/lf/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/errors_impl.py", line 466, in raise_exception_on_not_ok_status
    pywrap_tensorflow.TF_GetCode(status))
    tensorflow.python.framework.errors_impl.InvalidArgumentError: NodeDef mentions attr 'identical_element_shapes' not in Op<name=TensorArrayV3; signature=size:int32 -> handle:resource, flow:float; attr=dtype:type; attr=element_shape:shape,default=; attr=dynamic_size:bool,default=false; attr=clear_after_read:bool,default=true; attr=tensor_array_name:string,default=""; is_stateful=true>; NodeDef: Preprocessor/map/TensorArray = TensorArrayV3clear_after_read=true, dtype=DT_FLOAT, dynamic_size=false, element_shape=, identical_element_shapes=true, tensor_array_name="", _device="/job:localhost/replica:0/task:0/cpu:0". (Check whether your GraphDef-interpreting binary is up to date with your GraphDef-generating binary.).
    [[Node: Preprocessor/map/TensorArray = TensorArrayV3clear_after_read=true, dtype=DT_FLOAT, dynamic_size=false, element_shape=, identical_element_shapes=true, tensor_array_name="", _device="/job:localhost/replica:0/task:0/cpu:0"]]
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
    File "real_time_counting.py", line 31, in 
    object_counting_api.object_counting(input_video, detection_graph, category_index, is_color_recognition_enabled) # counting all the objects
    File "/home/lf/桌面/tensorflow_object_counting_api/api/object_counting_api.py", line 302, in object_counting
    feed_dict={image_tensor: image_np_expanded})
    File "/home/lf/anaconda3/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 895, in run
    run_metadata_ptr)
    File "/home/lf/anaconda3/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1124, in _run
    feed_dict_tensor, options, run_metadata)
    File "/home/lf/anaconda3/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1321, in _do_run
    options, run_metadata)
    File "/home/lf/anaconda3/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1340, in _do_call
    raise type(e)(node_def, op, message)
    tensorflow.python.framework.errors_impl.InvalidArgumentError: NodeDef mentions attr 'identical_element_shapes' not in Op<name=TensorArrayV3; signature=size:int32 -> handle:resource, flow:float; attr=dtype:type; attr=element_shape:shape,default=; attr=dynamic_size:bool,default=false; attr=clear_after_read:bool,default=true; attr=tensor_array_name:string,default=""; is_stateful=true>; NodeDef: Preprocessor/map/TensorArray = TensorArrayV3clear_after_read=true, dtype=DT_FLOAT, dynamic_size=false, element_shape=, identical_element_shapes=true, tensor_array_name="", _device="/job:localhost/replica:0/task:0/cpu:0". (Check whether your GraphDef-interpreting binary is up to date with your GraphDef-generating binary.).
    [[Node: Preprocessor/map/TensorArray = TensorArrayV3clear_after_read=true, dtype=DT_FLOAT, dynamic_size=false, element_shape=, identical_element_shapes=true, tensor_array_name="", _device="/job:localhost/replica:0/task:0/cpu:0"]]
    
    Caused by op 'Preprocessor/map/TensorArray', defined at:
    File "real_time_counting.py", line 17, in 
    detection_graph, category_index = backbone.set_model('ssd_mobilenet_v1_coco_2018_01_28')
    File "/home/lf/桌面/tensorflow_object_counting_api/utils/backbone.py", line 47, in set_model
    tf.import_graph_def(od_graph_def, name='')
    File "/home/lf/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/importer.py", line 313, in import_graph_def
    op_def=op_def)
    File "/home/lf/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 2630, in create_op
    original_op=self._default_original_op, op_def=op_def)
    File "/home/lf/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1204, in init
    self._traceback = self._graph._extract_stack() # pylint: disable=protected-access
    
    InvalidArgumentError (see above for traceback): NodeDef mentions attr 'identical_element_shapes' not in Op<name=TensorArrayV3; signature=size:int32 -> handle:resource, flow:float; attr=dtype:type; attr=element_shape:shape,default=; attr=dynamic_size:bool,default=false; attr=clear_after_read:bool,default=true; attr=tensor_array_name:string,default=""; is_stateful=true>; NodeDef: Preprocessor/map/TensorArray = TensorArrayV3clear_after_read=true, dtype=DT_FLOAT, dynamic_size=false, element_shape=, identical_element_shapes=true, tensor_array_name="", _device="/job:localhost/replica:0/task:0/cpu:0". (Check whether your GraphDef-interpreting binary is up to date with your GraphDef-generating binary.).
    [[Node: Preprocessor/map/TensorArray = TensorArrayV3clear_after_read=true, dtype=DT_FLOAT, dynamic_size=false, element_shape=, identical_element_shapes=true, tensor_array_name="", _device="/job:localhost/replica:0/task:0/cpu:0"]]
    I found the error tf.import_graph_def(od_graph_def, name= "). I don't know how to correct it. Could you please help me

通过上面的错误可以发现造成这样的错误的原因是:tf.import_graph_def(od_graph_def, name='')
但是,本质上这样的写是对的,而造成这样的原因是:tensorflow版本不符合,而我这里造成的原因是版本太低,这里要求tensorflow版本大于1.3,所以只需要升级大于1.3版本即可

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: 这个错误提示是在Python中出现的,意思是在sitecustomize模块中出现了错误,并且建议设置pythonverbose来获取详细的错误信息。具体的错误信息是NameError,即名称错误,其中'reload'这个名称没有被定义。可能是因为你在使用reload函数时没有正确导入相关的模块或库。你可以检查一下代码中是否有这样的问题,并尝试修复它。 ### 回答2: 这个错误是因为在Python代码中使用了reload()函数,但是这个函数在Python 3.x之后已经被移除了,因此导致了代码错误。通常是在使用旧版Python代码时出现这种错误。 解决这个错误的最简单方法是将代码中的reload()函数替换为importlib库的reload()方法。importlib.reload()在Python 3.x中提供了类似于reload()的功能。需要注意的是,reload()方法在Python 2.x中仍然可以使用,但在Python 3.x中应该使用importlib库的reload()方法。 另外,也可以通过升级Python版本来解决这个错误。如果您使用的是Python 2.x版本,可以考虑升级到Python 3.x版本,这样就可以避免这个错误。当然,升级Python版本可能会带来其他代码兼容性的问题,需要注意。 总之,解决这个错误的方法是替换代码中的reload()函数,并且需要注意Python版本的兼容性。如果遇到其他代码错误,可以通过查看错误信息的提示来进行相应的解决。 ### 回答3: 首先,这个错误信息表明在运行 Python 程序时出现了问题。第一行中的 “error in sitecustomize” 表明错误出现在 sitecustomize 模块中,该模块是 Python 程序的一个配置文件,其主要功能是自定义 Python 解释器的环境变量和默认模块。 第二行中的 “set pythonverbose for traceback” 要求我们设置 Python 的详细模式,以便查看错误轨迹。而第三行的 “nameerror: name 'reload' is not defined” 是指出现了名字错误,并且指定的 ‘reload’ 函数不存在。 问题可能出现在多个地方,但最有可能的情况是:程序试图使用 “reload” 函数来重新加载 Python 模块,但是这个函数在 Python 3.x 版本中被移除了。 如果你使用的是 Python 2.x 版本,则可以尝试重新导入 reload() 函数。具体方法是:在程序中添加以下代码即可。 ``` from imp import reload ``` 在 Python 3.x 版本中,为了实现动态重载模块,需要使用 importlib 模块。您可以在程序中添加以下代码实现: ``` import importlib importlib.reload(module_name) ``` 如果你确定已经按照上述方法进行了更改,但仍然出现上述错误,则可以考虑检查程序中其他未定义的函数,并重新编写程序以避免使用这些函数。 总之,要解决这个错误,需要仔细检查程序并查找并修复存在的问题。在实际编程过程中,要注意 Python 版本之间的差异,以避免出现不必要的错误。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值