Compute total loss error

The inputs to the TF cost function need to be in “samples first” orientation. If the question is why it needs to be this way, please see this thread.