That’s because there’s Dropout inside the model and it applies a different mask to each batch element at each forward. If you want to disable it call model.eval() to put it in evaluation mode.

As a side note, don’t use == to compare floats. Floating point operations are slightly inaccurate and can differ by very small amounts. Use (tensor1 - tensor2).abs().max() to find the maximal difference between the outputs (and assume they’re equal if it’s very small, e.g. 1e-10).