albanD:

I’m not 100% sure why you need to clone here, I think detaching and requiring gradient again would work.


Thanks! Seems to work. Final version: Mini-batching within the model in PyTorch · GitHub 1