Deriving the structure of a pytorch network
问题 For my use case, I require to be able to take a pytorch module and interpret the sequence of layers in the module so that I can create a “connection” between the layers in some file format. Now let’s say I have a simple module as below class mymodel(nn.Module): def __init__(self, input_channels): super(mymodel, self).__init__() self.fc = nn.Linear(input_channels, input_channels) def forward(self, x): out = self.fc(x) out += x return out if __name__ == "__main__": net = mymodel(5) for mod in