sqrt method

Value sqrt()

Implementation

Value sqrt() {
  if (data < 0) {
    throw Exception("Square root of a negative number is undefined.");
  }
  final result = math.sqrt(data);
  final out = Value(result, {this}, 'sqrt');
  out._backward = () {
    grad += (0.5 / result) * out.grad;
  };
  return out;
}