Added CHECK if loss is NaN

As mentioned in #1349 If Loss is Nan it doesn't make sense to keep training.
Could "due to" be misleading here? It may be that the NaN appears in some low layer but gets propagated up to the loss... (there are really two possible meanings of "due to" here, and I know which one you mean now, but I'm worried I'll forget when I see this message later).