Implement lib/loss-func.rb