Var
Defined in: tape.js:18
A node in the computation graph.
Constructors
Constructor
new Var(
value,parents?,backward?,recompute?,spec?):Var
Defined in: tape.js:31
Parameters
value
Tensor
forward value
parents?
Var[] = []
inputs this node was computed from
backward?
(g) => Float64Array<ArrayBufferLike>[]
given the
gradient of the root w.r.t. this node’s value, return the contribution to
each parent, in parents order. null skips a parent (e.g. an integer
index argument), which is cheaper than allocating a zero buffer.
recompute?
() => void
recompute this node’s forward
value IN PLACE from its parents’ current values. Present on every op,
absent on leaves. compile() replays a graph through these; see the
in-place invariant documented on node.
spec?
any = null
Returns
Var
Properties
_backward
_backward: (
g) =>Float64Array<ArrayBufferLike>[]
Defined in: tape.js:34
Parameters
g
Float64Array
Returns
Float64Array<ArrayBufferLike>[]
_recompute
_recompute: () =>
void
Defined in: tape.js:35
Returns
void
grad
grad:
Float64Array<ArrayBufferLike>
Defined in: tape.js:44
parents
parents:
Var[]
Defined in: tape.js:33
spec
spec:
object
Defined in: tape.js:42
How to rebuild this node from its parents: the op’s exported name and its static (non-Var) arguments. What lets a compiled plan be written out as data and rebuilt elsewhere. Null on a leaf.
args?
optionalargs?:any[]
list?
optionallist?:boolean
op
op:
string
value
value:
Tensor
Defined in: tape.js:32
Accessors
data
Get Signature
get data():
Float64Array<ArrayBufferLike>
Defined in: tape.js:51
Returns
Float64Array<ArrayBufferLike>
isScalar
Get Signature
get isScalar():
boolean
Defined in: tape.js:56
True for a rank-0 node, the only kind backward() can seed on its own.
Returns
boolean
shape
Get Signature
get shape():
number[]
Defined in: tape.js:47
Returns
number[]
Methods
backward()
backward(
seed?):Var
Defined in: tape.js:67
Accumulate gradients through the graph, from this node backwards.
Parameters
seed?
Float64Array<ArrayBufferLike> | number[]
gradient of the objective w.r.t. this node. Required unless the node is a scalar, where it defaults to 1.
Returns
Var