Flipping a tensor along an axis in forward()

Does flipping a tensor in forward() function of a model affect the autograd? I flipped the input to pass it through the recurrent layer and then flipped the result back, but it was not performing as well as when the inputs and targets were flipped from the beginning before passing it through the model.

if you are using built-in function torch.flip, no it doesnt

1 Like

So flipping the tensor in forward() function and passing pre-flipped inputs to the forward will be different?

it will be the same. sorry for not being clear. I meant that it won’t break autograd.

1 Like

Thanks :slight_smile: