Two questions:


If you only want 5 examples to affect your loss (and consequently to be used for backprop), why don’t you set your batch_size to 5 instead of 10?


What do you really aim to compute with loss[1].backward()? (Note that a loss function should be a scalar function, i.e. it should return a scalar and not a vector…)