[英]Why can't PyCharm show PyTorch Module object attributes in debug mode
I define a sub-class of PyTorch's Module
in PyCharm and create an instance a
:我在 PyCharm 中定义了 PyTorch
Module
的子类并创建了一个实例a
:
from torch.nn import Module
class AModule(Module):
def __init__(self):
self.something = 10
def __repr__(self):
return "AModule"
a = AModule()
If I run the debugger and examine a
, I can't see its attributes:如果我运行调试器并检查
a
,我看不到它的属性:
I checked and Module
is written in Python (as opposed to being implemented in C), so why is that?我检查了一下,
Module
是用 Python 编写的(而不是用 C 实现),那是为什么呢?
This is caused by not having properly initialized Module
with a super
call in the first like of __init__
:这是由于在
super
之类的第一个调用中没有正确初始化Module
__init__
的:
super(AModule, self).__init__()
However, PyCharm could have shown more useful information, so I created this issue .然而,PyCharm 可以显示更多有用的信息,所以我创建了这个问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.