operator - method

Node operator -(
  1. Node other
)

Implementation

Node operator -(Node other) {
  final out = Node(value - other.value, '-');
  out._parents = [this, other];
  out._backward.add(() {
    this.grad += out.grad;
    other.grad -= out.grad;
    if (jacobian != null && other.jacobian != null) {
      for (int i = 0; i < jacobian!.length; i++) {
        for (int j = 0; j < jacobian![i].length; j++) {
          jacobian![i][j] -= other.jacobian![i][j];
        }
      }
    }
  });
  return out;
}