Fix for overflow, and loss computation
test regularisation