Questions in ensemble

I want to combine several model predictions together to achieve a better result,

for cnt, (images, labels) in enumerate(data_loader):
images, labels = Variable(images), Variable(labels)
outputs = torch.exp(net.forward(images))
if counter == 1:
bmv.append(outputs)
else:
bmv[cnt] += outputs # the place the memory explodes

If I replace += with =, there is no problem. I don’t know the reason. Waiting for answers

Furthermore, it didn’t get better even I change outputs to int. The memory still explodes in the same iteration.

You are adding the whole graph to bmv, which is why you need more memory in each iteration.
If you only need the output without its graph stored/added in bmv, use outputs.data and have a look if your memory consumption still grows.

The problem is solved, thanks a lot.