Storing them in a list and then doing pred_tensor = torch.cat(list_of_preds, dim=0) should do the right thing. I would personally use y_pred(output.detach().cpu()) and store a list of torch.Tensors, leaving the conversion to numpy array for later (or you might see if the array interface does its magic, with Matplotlib it often does).