autograd

package module
v0.0.0-...-e2bb1e6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 29, 2025 License: MIT Imports: 2 Imported by: 1

README

Autograd

this is a simple autograd library i wrote in go.

there are examples of training on XOR and MNIST in examples/xor, and examples/mnist respectively.

Installation

go get -u github.com/olimci/autograd

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Backward

func Backward(root *Node)

func SGD

func SGD(params []*Node, lr float32)

func ZeroGrads

func ZeroGrads(params []*Node)

Types

type Edge

type Edge struct {
	Parent   *Node
	Backward func(dy *tensor.Tensor[float32])
}

type Node

type Node struct {
	Val       *tensor.Tensor[float32]
	Grad      *tensor.Tensor[float32]
	WantsGrad bool
	Parents   []*Edge
}

func Add

func Add(a, b *Node) *Node

func Const

func Const(v *tensor.Tensor[float32]) *Node

func Conv

func Conv(
	x, w, b *Node,
	sH, sW, pH, pW int,
) *Node

func Div

func Div(a, b *Node) *Node

func Exp

func Exp(x *Node) *Node

func Fill

func Fill(x *Node, shape ...int) *Node

func FillLike

func FillLike(x *Node, target *Node) *Node

func Log

func Log(x *Node) *Node

func MakeResult

func MakeResult(val *tensor.Tensor[float32], deps ...*Node) *Node

func MatMul

func MatMul(a, b *Node) *Node

func Max

func Max(x *Node) *Node

func Mean

func Mean(x *Node) *Node

func Min

func Min(x *Node) *Node

func Mul

func Mul(a, b *Node) *Node

func Neg

func Neg(x *Node) *Node

func Param

func Param(v *tensor.Tensor[float32]) *Node

func Sub

func Sub(a, b *Node) *Node

func Sum

func Sum(x *Node) *Node

func Vec

func Vec(data ...float32) *Node

func (*Node) AddEdge

func (n *Node) AddEdge(parent *Node, backward func(dy *tensor.Tensor[float32]))

Directories

Path Synopsis
examples
mnist command
xor command
module module
tensor module

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL