class Num::Grad::Context(T)
inherits Reference
#
Constructors#
Methods#
#no_grad : Bool
#
: Bool
If no_grad is set to true, operations will not be cached, and backpropogation will not be possible
#nodes : Array(Num::Grad::Node(T))
#
: Array(Num::Grad::Node(T))
A list of all variables present in an operation. This list can contain duplicates
#variable(value : Number, requires_grad : Bool = true) : Num::Grad::Variable(T)
#
(value : Number, requires_grad : Bool = true) : Num::Grad::Variable(T)
Creates a new variable within the Context
. This variable
must be able to be cast to a Tensor
of type T
.
Arguments#
- value :
Number
-Number
to be monitored - requires_grad :
Bool
- Flag to indicate if operations should be cached for this variable
Examples#
ctx = Context(Tensor(Float64)).new
ctx.variable(3.0)
#variable(value : Array, requires_grad : Bool = true) : Num::Grad::Variable(T)
#
(value : Array, requires_grad : Bool = true) : Num::Grad::Variable(T)
Creates a new variable within the Context
. This variable
must be able to be cast to a Tensor
of type T
.
Arguments#
- value :
Array
-Array
to be monitored - requires_grad :
Bool
- Flag to indicate if operations should be cached for this variable
Examples#
ctx = Context(Tensor(Float64)).new
ctx.variable([1.0, 2.0, 3.0])
#variable(value : T, requires_grad : Bool = true) : Num::Grad::Variable(T)
#
(value : T, requires_grad : Bool = true) : Num::Grad::Variable(T)
Creates a new variable within the Context
. This variable
must be able to be cast to a Tensor
of type T
.
Arguments#
- value :
Tensor
-Tensor
to be monitored - requires_grad :
Bool
- Flag to indicate if operations should be cached for this variable
Examples#
ctx = Context(Tensor(Float64)).new
ctx.variable([1.0, 2.0, 3.0].to_tensor)