Hello everyone, I have a question about hook functions:
After executing the following code:
def relu_backward_deconv_hook(module, grad_input, grad_output): 
    return nn.functional.relu(grad_output[0])

def equip_model_deconv(model): 
    for m in model.modules():
        if isinstance(m, nn.ReLU): 
            m.register_backward_hook(relu_backward_deconv_hook)


def grad_view(model, image_name):
    to_tensor = transforms.ToTensor()
    img = to_tensor(PIL.Image.open(image_name))
    img = img[:,0:224,0:224]
    img = 0.5 + 0.5 * (img - img.mean()) / img.std()
    
    model.to(device='cuda:0')
    img = img.to(device='cuda:0')
    
    input1 = img.view(1, img.size(0), img.size(1), img.size(2)).requires_grad_() 
    print(tuple(input1.shape))
    output = model(input1)
    result = torch.autograd.grad(output.max(), input1)
    
    result = result / result.max() + 0.5
    
    return result

model = models.vgg16(pretrained = True) 
model.eval()
model = model.features 

equip_model_deconv(model)
result = grad_view(model, "/home/ubuntu/folder/mug.jpg") 
utils.save_image(result, 'mug-vgg16-deconv.png')

I get this error: TypeError: expected tuple, but hook returned ‘Tensor’
Could you figure out the problem that I’m having?
Thank you in advance!