Yes, since you are currently overwriting it.
Since you are using phase to switch between train and valid, you could store the losses in a dict using the same keys:
losses = {}
for phase in ['train', 'valid']:
    ...
    losses[phase] = epoch_loss