Skip to content

royru/micrograd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

micrograd

As inspired by Andrej Karpathy's micrograd and the lecture about it.

use micrograd::Value;

let a = Value::val(3.0);
let b = Value::val(2.0);
let c = b.mul(&a);
c.backwards();

assert_eq!(a.get_grad(), 2.0);

You can also define a MLP and train it:

use micrograd::MLP;

let mlp = MLP::new(&vec![2, 4, 1]);
let x = vec![2.0, 3.0];
let y = -1.0;

for _ in 0..20 {
  mlp.train(&x, y);
}

mlp.predict(&x) // hopefully close to -1

About

dummy implementation in rust

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages