Skip to content

SXsid/micrograd-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MicroGrad

A minimal neural network and autograd engine written in Go.

Computation Graph

MicroGrad is a scalar-valued autograd engine, computation graph, backpropagation, and a simple Multi-Layer Perceptron (MLP) built from scratch without any external machine learning libraries.

Architecture

Value
├── data
├── grad
├── source nodes
└── backward function

Neuron
├── weights
├── bias
└── activation

Layer
└── collection of neurons

MLP
└── collection of layers

Training Example

for i := 0; i < 100; i++ {
    output := mlp.Init(input)

    loss := Loss(target, output)

    for _, p := range mlp.Params() {
        p.grad = 0
    }

    loss.Backward()

    for _, p := range mlp.Params() {
        p.data += -0.01 * p.grad
    }

    fmt.Println(loss.data)
}

A simple gradient descent training loop using backpropagation.

References

About

A Go implementation of a scalar-valued autograd engine with an MLP built on top.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages