crossEntropy method

Value crossEntropy(
  1. ValueVector target
)

Implementation

Value crossEntropy(ValueVector target) {
  assert(target.values.length == values.length);
  Value loss = Value(0.0);

  for (int i = 0; i < values.length; i++) {
    loss += (-target.values[i]) * (values[i].log());
  }
  return loss;
}