class Num::Grad::Context(T)
- Num::Grad::Context(T)
- Reference
- Object
Defined in:
grad/primitives/context.crConstructors
-
.new
Contexts can only be initialized as empty, and a generic type must be provided
Instance Method Summary
- #last : Num::Grad::Node(T)
-
#no_grad : 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))
A list of all variables present in an operation.
-
#variable(value : Number, requires_grad : Bool = true) : Num::Grad::Variable(T)
Creates a new variable within the
Context
. -
#variable(value : Array, requires_grad : Bool = true) : Num::Grad::Variable(T)
Creates a new variable within the
Context
. -
#variable(value : T, requires_grad : Bool = true) : Num::Grad::Variable(T)
Creates a new variable within the
Context
.
Constructor Detail
Instance Method Detail
If no_grad is set to true, operations will not be cached, and backpropogation will not be possible
A list of all variables present in an operation. This list can contain duplicates
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)
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])
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)