Model.eval badly affect my model

As the title, I use a encoder-decoder to generate an image which is identical to itself/input.Settings are as usual.
But the result are different when I checking it during training loop and doing the evaluation independently.
in the training loop:

model.eval()
    with  torch.no_grad():
        origin=origin.to(device)
        result=model(origin)
        grid=make_grid(result)
        save_image(grid,filename='./snapshot/images/{:d}/{:d}.jpg'.format(i,index))

this result is not good.


next I do the evaluation independently.

with torch.no_grad():
    model=Network()
    model=torch.nn.DataParallel(model,device_ids=[1])
    model.to(device)
    util.load_ckpt(1360,[('model', model)])
    result=model(origin)
    grid=torchvision.utils.make_grid(result)

that one is the correct one.

Finally I found that as long as I use the model.eval() api, no matter wherever ,the result appears color shift,and the shift doesn’t even have any clear direction.some epoch seems red, some epoch seems yellow, some epoch seems blue, whatever.
When I add mode.eval() into the evaluation code, thre result is same as its counterpart inside the training loop.
Could anyone help me about it? I just found the key problem that puzzled me lots of days,But I don’t know the reason and how to prevent it.
Besides, the result seems not normalized when use eval(). result min=-1.7,max=5.5,but when I comment it and use the torch.no_grad() only, it becomes min=-0.07,max=1.5(I didn’t apply a normalization on the result, they are applied inside the network)

Do you have nn.BatchNorm layers in your model?
If so, you could play around with the momentum a bit, as it might be the running estimates do not capture the your data distribution.