tensorboardX: add_graph() show error 'torch._C.Value' object has no attribute 'uniqueName' with torch 1.2.0

Describe the bug add_graph() with torch 1.2.0 will show error ‘torch._C.Value’ object has no attribute ‘uniqueName’ but work well with torch 1.1.0

Minimal runnable code to reproduce the behavior

from tensorboardX import SummaryWriter
class LeNet(nn.Module):
    def __init__(self):
        super(LeNet, self).__init__()
        self.conv1 = nn.Sequential(     #input_size=(1*28*28)
            nn.Conv2d(1, 6, 5, 1, 2),
            nn.ReLU(),      #(6*28*28)
            nn.MaxPool2d(kernel_size=2, stride=2),  #output_size=(6*14*14)
        )
        self.conv2 = nn.Sequential(
            nn.Conv2d(6, 16, 5),
            nn.ReLU(),      #(16*10*10)
            nn.MaxPool2d(2, 2)  #output_size=(16*5*5)
        )
        self.fc1 = nn.Sequential(
            nn.Linear(16 * 5 * 5, 120),
            nn.ReLU()
        )
        self.fc2 = nn.Sequential(
            nn.Linear(120, 84),
            nn.ReLU()
        )
        self.fc3 = nn.Linear(84, 10)

    def forward(self, x):
        x = self.conv1(x)
        x = self.conv2(x)
        x = x.view(x.size()[0], -1)
        x = self.fc1(x)
        x = self.fc2(x)
        x = self.fc3(x)
        return x

dummy_input = torch.rand(13, 1, 28, 28)
model = LeNet()
with SummaryWriter(comment='Net', log_dir='/output') as w:
    w.add_graph(model, (dummy_input, ))

Expected behavior

Screenshots

Environment

Python environment Python 3.6

Additional context Add any other context about the problem here.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 5
  • Comments: 18 (4 by maintainers)

Commits related to this issue

Most upvoted comments

same with python=3.7.4, torch=1.2.0

try to build from source with :

git clone https://github.com/lanpa/tensorboardX && cd tensorboardX && python setup.py install

@lanpa tensorboardX will not show any error if I follow your fix.

Since pytorch 1.3 is officially released and works with tensorboardX 1.9, closing this.

I am encountering the same issue when calling hiddenlayer.build_graph method: In order to fix it in hiddenlayer\pytorch_builder.py, change get_shape method to:

def pytorch_id(node):
    """Returns a unique ID for a node."""
    # After ONNX simplification, the scopeName is not unique anymore
    # so append node outputs to guarantee uniqueness
    return node.scopeName() + "/outputs/" + "/".join([o.debugName() for o in node.outputs()])

Packages information: torch 1.2.0+cu10 matplotlib 3.1.1 tensorflow 1.14.0 graphviz 0.12 hiddenlayer 0.2 python 3.7.4