torchview icon indicating copy to clipboard operation
torchview copied to clipboard

How can I force a member variable to appear as nested?

Open miccio-dk opened this issue 1 year ago • 1 comments

Hi :) As per title, I have a model containing a couple of custom layers, implemented by inheriting from nn.Module. However, they do not appear as nested blocks in my graph, even tho I have "expand_nested=True". All the relevant operations performed by the module do appear, but they're just thrown around based on the execution order. How can I ensure that a given module/element appears in the graph as a nested module?

Thank you so much in advance for the amazing package (and hopefully for the help ;) )

miccio-dk avatar Aug 14 '23 10:08 miccio-dk

I figured out that the layer needs to call its forward function to be properly featured in the graph. I was calling a separate method (with a different name) and that caused it to not be recognized by torchview.

miccio-dk avatar Aug 21 '23 10:08 miccio-dk