yes，I want to fetch the input and output of each layer, I try to use the global variable in the fun function to fetch, but the fetched variable can not be changed to numpy, suggesting that ‘tuple’ object has no attribute ‘numpy’ In the following code

def fun(self,input,output):
    print('Inside '+ self.__class__.__name__ +'forward')
    print('')
    #print('input: ',input)
    global xg
    xg=input
model.conv2.register_forward_hook(fun)
out = model(input)
xi=xg
xi=xi.numpy()


so,If hook can not solve my problem, there are other ways to solve my problem?
forward can fetch the input and output of each layer? thank you very much