class MicroGrad::Value(T)

Overview

Stores a single scalar value and its gradient

Defined in:

micrograd/engine.cr

Class Method Summary

Instance Method Summary

Class Method Detail

def self.[](num : Number) #

Initialize a Value(T) with a Number; useful for casting different scalars into a Value


[View source]

Instance Method Detail

def *(other : Value) #

Multiply this Value with another and return the result as a Value chained with the inputs.


[View source]
def *(other : Number) #

Multiple this Value with any Number (internally wrapping that in a Value) and return the result as a Value chained with the inputs.


[View source]
def **(other : Number) #

Calculate this value's data to the power of the given scalar and return the result as a Value chained with the inputs.


[View source]
def +(other : Value) #

Add this Value to another and return the result as a Value chained with the inputs.


[View source]
def +(other : Number) #

Add this Value to any Number (internally wrapping that in a Value) and return the result as a Value chained with the inputs.


[View source]
def -(other : Value) #

Subtract another Value from this one and return the result as a Value chained with the inputs.


[View source]
def -(other : Number) #

Subtract any Number from this Value (internally wrapping that in a Value) and return the result as a Value chained with the inputs.


[View source]
def - #

Negate this Value and return the result as a Value chained with the inputs.


[View source]
def /(other : Value) #

Divide this Value by another and return the result as a Value chained with the inputs.


[View source]
def /(other : Number) #

Divide this Value by any Number (internally wrapping that in a Value) and return the result as a Value chained with the inputs.


[View source]
def backward #

Calculate the gradients backwards from this Value


[View source]
def data : T #

[View source]
def data=(value : Number) #

Assign a data value


[View source]
def draw_dot(io, graph_name = "X") #

Generate a Graphviz dot digraph diagram to the io; the output can be converted to an image using the dot tool.


[View source]
def exp #

Power of e


[View source]
def grad : T #

[View source]
def grad=(value : Number) #

Assign a gradient


[View source]
def log #

Natural log


[View source]
def relu #

ReLU


[View source]
def sigmoid #

Sigmoid


[View source]
def tanh #

tanh


[View source]
def to_s(io) #

Return a string describing the data and gradient of this Value


[View source]