This is really ugly. I wish I could do without an if condition. Something like epochs = [] outside the loop and then np.append() inside the loop, but that doesn't work ...