How to change result of forward pass?

Hi fellow pytorchers,

I would like to change the result of a certain layer in the forward pass, for instance to choose the entries zeroed by ReLU. I know that using forward_hook is not an option, since it does not allow one to change the output of the layer. Is there any other way?

yes, directly just change the Tensor.
For example:

x = ReLU(input)
x[x.eq(0)] = 4