I’m Newbie on pytorch.
Now, I would like to see the values (input, output, weight, bias, and gradient) of each layer in reverse order using hook during test. How can I access the each layer?
class Net(nn.Module):
    def __init__(self):
        super(Net, self).__init__()
        # 1 input image channel, 6 output channels, 5x5 square convolution
        # kernel
        self.layer = nn.Sequential(OrderedDict([
            ('conv1', nn.Conv2d(1, 6, 5)),
            ('relu1', nn.ReLU()),
            ('mp1', nn.MaxPool2d((2, 2))),
            ('conv2', nn.Conv2d(6, 16, 5)),
            ('relu2', nn.ReLU()),
            ('mp2', nn.MaxPool2d((2, 2)))
        ]))
        self.fc_layer = nn.Sequential(OrderedDict([
            ('fc1', nn.Linear(256, 120)),
            ('fc_relu1', nn.ReLU()),
            ('fc2', nn.Linear(120, 84)),
            ('fc_relu2', nn.ReLU()),
            ('fc3', nn.Linear(84, 10)),
        ]))

    def forward(self, x):
        in_size = x.size(0)
        x = self.layer(x)
        x = x.view(in_size, -1)  # flatten the tensor
        x = self.fc_layer(x)
        return F.log_softmax(x, dim=1)

model = Net()
# For Forward Hook
for name, module in model.layer.named_children():
    print(name)
    module.register_forward_hook(printnorm)
for name, module in model.fc_layer.named_children():
    print(name)
    module.register_forward_hook(printnorm)

def test():

        for name, module in model.layer.named_children()
            module.output.shape