Hi Im facing the same problem. How did you ensure the shift? Im not sure how to do it: Im using padded sequences as target input: e.g. target_tensor = [1,2,3,4,5,99,0,0,0,0,0,0] (1 is sos-token, 99 is eos-token, cutting the last element doesnt make sense here, since it s a padding token.) I tried to switch the token with target_tensor[target_tensor == 99] = 0 whcih results in an grading error.
Also maybe @Agnes could you provide more parts of the code Im not sure where to initialize the code? In init? or outside the model?
Looking at this example 10  none of the things @agnes wrote seems necessary? Is there any explanation for that?
Adding this discussion 3 which descibes a similar apporach to @agnes