class

ML::Autograd::GradFn

Inherits Reference / Object

Base class for gradient functions Each operation creates a GradFn that knows how to compute gradients

Constructors

new(name : String)
Source

Instance methods

backward(grad_output : Tensor) : Array(Tensor | Nil)

Compute gradients w.r.t. inputs given gradient of output Returns array of gradients, one per input (or nil if input doesn't require grad)

Source
inputs

Inputs that contributed to this operation Stored as weak references to avoid cycles

Source
inputs=(inputs : Array(Variable))

Inputs that contributed to this operation Stored as weak references to avoid cycles

Source
name

For debugging

Source
num_inputs

Number of inputs this operation takes

Source