Node constructor

Node(
  1. List<Tensor> inputs,
  2. Function backwardFn, {
  3. String opName = 'op',
  4. int cost = 0,
  5. Map<String, dynamic> extraParams = const {},
})

A Node connects different Tensor together. Nodes can be viewed inside a computational graph as functions holding references to its input tensors. To allow backpropagation through the network backwardFn is stored as a reference to the given method. Nodes are used for eager cpu execution of functions.

cost is used as an approximate value to allow diagnosing and debugging a systems performance.

opName is used to give a function a recognisable name for debugging and traceability.

extraParams allows to store additional arguments fe. an integer describing recursive depth used in the function.

Nodes are mostly used within the creation and coupling of new Tensor,

Example:

  out.creator = Node(
    [a, b],
        () {
      a.grad[0] = a.grad[0] + out.grad[0];
      b.grad[0] = b.grad[0] + out.grad[0];
    },
    opName: 'add',
    cost: 1,
  );

Implementation

Node(
  this.inputs,
  this.backwardFn, {
  this.opName = 'op',
  this.cost = 0,
  this.extraParams = const {},
});