tensorflow TypeError: Descriptors cannot not be created directly.
时间: 2023-09-18 20:16:17 浏览: 58
这个错误通常意味着你试图直接创建描述符,而不是使用正确的方法。在 TensorFlow 中,描述符是用于定义计算图中的操作的对象。
要解决这个错误,你需要使用适当的 TensorFlow API 方法来创建描述符。具体可以根据你的具体情况和代码片段来确定。
如果你能提供更多的上下文或代码片段,我可以给出更具体的帮助。
相关问题
TypeError: Descriptors cannot not be created directly.
This error occurs when you try to create descriptors directly instead of using them as part of a class definition. Descriptors are special objects that are used to define attributes of a class, and they need to be defined within the class definition.
For example, if you want to define a descriptor for a specific attribute of a class, you would define it like this:
```
class MyDescriptor:
def __get__(self, instance, owner):
# code to get the attribute value
pass
def __set__(self, instance, value):
# code to set the attribute value
pass
class MyClass:
my_attr = MyDescriptor()
```
In this example, `MyDescriptor` is defined within the class definition of `MyClass`, and `my_attr` is an attribute of `MyClass` that is defined using `MyDescriptor`.
If you try to create `MyDescriptor` outside of the class definition, you will get the "TypeError: Descriptors cannot not be created directly" error:
```
my_descriptor = MyDescriptor() # TypeError: Descriptors cannot not be created directly
```
TypeError: Descriptors cannot not be created directly
TypeError: Descriptors cannot not be created directly是一个错误信息,它通常出现在运行深度学习python程序时,如mmdetection、mmdetection3d等程序中。这个错误提示意味着不能直接创建descriptors(描述符)。
解决这个问题的方法是重新安装pyqt5,可以使用以下命令进行安装:pip install protobuf==pyqt5。另外,也可以尝试降级protobuf包到3.20.x或更低版本,或者设置PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python来使用纯Python解析,但会导致解析速度变慢。
需要注意的是,如果此错误提示来自_pb2.py文件,那么可能是生成的代码已过时,需要使用protoc >= 3.19.0重新生成protos文件。如果无法立即重新生成protos文件,可以尝试上述提到的其他解决方法。
希望这些信息能帮助你解决TypeError: Descriptors cannot not be created directly的问题。如果还有其他问题,请随时提问。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* *3* [Descriptors cannot not be created directly](https://blog.csdn.net/suiyingy/article/details/125218783)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 100%"]
[ .reference_list ]