user118967
user118967

Reputation: 5742

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:

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:

enter image description here

I checked and Module is written in Python (as opposed to being implemented in C), so why is that?

Upvotes: 2

Views: 268

Answers (1)

user118967
user118967

Reputation: 5742

This is caused by not having properly initialized Module with a super call in the first like of __init__:

super(AModule, self).__init__()

However, PyCharm could have shown more useful information, so I created this issue.

Upvotes: 1

Related Questions