Don't Understand Loss Calculation

It’s driving me nuts, it seems I’m doing everything okay, including the loss calculation, but still the model and training specified here aren’t working…