How to get intermediate result, make some modifications to it, and then feed it back into the next layer?

Hello,

I was using TensorFlow and Keras which has a nice and simple option to get the output of the intermediate layer and then I can feed the same data back into the next layer

Is there something similar available in PyTorch without having to retrain the model?

Kind regards,
Greg

hi @gregorymjenson

Check out hooks in pytorch docs

https://pytorch.org/docs/stable/generated/torch.Tensor.register_hook.html